Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-05-27 08:00:04
Exec Total Coverage
Lines: 8560 12261 69.8%
Functions: 72 106 67.9%
Branches: 5434 10016 54.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #ifndef __GTHREAD_HIDE_WIN32API
16 #define __GTHREAD_HIDE_WIN32API 1
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <stdio.h>
22 #include <string.h>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <assert.h>
27 #include <fmt/format.h>
28
29
30 #include "metadata/sigs/devsig.h.sig"
31 #include "metadata/sigs/compilersig.h.sig"
32 #include "metadata/versionsig.h"
33 #include "base/zc_alleg.h"
34 #include "base/zdefs.h"
35 #include "base/colors.h"
36 #include "tiles.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 //#include "zquest.h"
40 #include "defdata.h"
41 #include "subscr.h"
42 #include "font.h"
43 #include "zc_custom.h"
44 #include "sfx.h"
45 #include "md5.h"
46 #include "ffscript.h"
47 #include "particles.h"
48 #include "dialog/alert.h"
49
50 #ifdef __EMSCRIPTEN__
51 #include "base/emscripten_utils.h"
52 #endif
53
54 //FFScript FFCore;
55 extern FFScript FFCore;
56 extern ZModule zcm;
57 extern zcmodule moduledata;
58 extern uint8_t __isZQuest;
59 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
60 extern particle_list particles;
61 extern void setZScriptVersion(int32_t s_version);
62 //FFSCript FFEngine;
63
64 int32_t temp_ffscript_version = 0;
65 static bool read_ext_zinfo = false, read_zinfo = false;
66 static bool loadquest_report = false;
67 static char const* loading_qst_name = NULL;
68 static byte loading_qst_num = 0;
69
70 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
71 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
72
73 #ifdef _MSC_VER
74 #define strncasecmp _strnicmp
75 #endif
76
77 #ifndef _AL_MALLOC
78 #define _AL_MALLOC(a) _al_malloc(a)
79 #define _AL_FREE(a) _al_free(a)
80 #endif
81
82 using std::string;
83 using std::pair;
84
85 // extern bool debug;
86 extern int32_t hero_animation_speed; //lower is faster animation
87 extern std::vector<mapscr> TheMaps;
88 extern zcmap *ZCMaps;
89 extern MsgStr *MsgStrings;
90 extern DoorComboSet *DoorComboSets;
91 extern dmap *DMaps;
92 extern newcombo *combobuf;
93 extern byte *colordata;
94 //extern byte *tilebuf;
95 extern tiledata *newtilebuf;
96 extern byte *trashbuf;
97 extern itemdata *itemsbuf;
98 extern wpndata *wpnsbuf;
99 extern comboclass *combo_class_buf;
100 extern guydata *guysbuf;
101 extern ZCHEATS zcheats;
102 extern zinitdata zinit;
103 extern char palnames[MAXLEVELS][17];
104 extern int32_t memrequested;
105 extern char *byte_conversion(int32_t number, int32_t format);
106 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
107 33 string zScript;
108 33 std::map<int32_t, script_slot_data > ffcmap;
109 33 std::map<int32_t, script_slot_data > globalmap;
110 33 std::map<int32_t, script_slot_data > genericmap;
111 33 std::map<int32_t, script_slot_data > itemmap;
112 33 std::map<int32_t, script_slot_data > npcmap;
113 33 std::map<int32_t, script_slot_data > ewpnmap;
114 33 std::map<int32_t, script_slot_data > lwpnmap;
115 33 std::map<int32_t, script_slot_data > playermap;
116 33 std::map<int32_t, script_slot_data > dmapmap;
117 33 std::map<int32_t, script_slot_data > screenmap;
118 33 std::map<int32_t, script_slot_data > itemspritemap;
119 33 std::map<int32_t, script_slot_data > comboscriptmap;
120 void free_newtilebuf();
121 bool combosread=false;
122 bool mapsread=false;
123 bool fixffcs=false;
124 bool fixpolsvoice=false;
125
126
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
127
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
128
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
129
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
130
131 char qstdat_string[2048] = { 0 };
132
133 static zinfo* load_tmp_zi = NULL;
134
135 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
136 const byte clavio[9]={97,109,111,110,103,117,115,0};
137
138 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
139 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
140
141 extern combo_alias combo_aliases[MAXCOMBOALIASES];
142 extern combo_pool combo_pools[MAXCOMBOPOOLS];
143 const char *qst_error[] =
144 {
145 "OK","File not found","Invalid quest file",
146 "Version not supported","Obsolete version",
147 "Missing new data" , /* but let it pass in ZQuest */
148 "Internal error occurred", "Invalid password",
149 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
150 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
151 };
152
153 //for legacy quests -DD
154 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
155 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
156 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
157 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
158 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
159 };
160
161 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
162
163
164 void delete_combo_aliases()
165 {
166 for(int32_t j(0); j<256; j++)
167 {
168 if(combo_aliases[j].combos != NULL)
169 {
170 delete[] combo_aliases[j].combos;
171 combo_aliases[j].combos=NULL;
172 }
173
174 if(combo_aliases[j].csets != NULL)
175 {
176 delete[] combo_aliases[j].csets;
177 combo_aliases[j].csets=NULL;
178 }
179 }
180
181 }
182
183 char *byte_conversion(int32_t number, int32_t format)
184 {
185 static char num_str[40];
186
187 if(format==-1) //auto
188 {
189 format=1; //bytes
190
191 if(number>1024)
192 {
193 format=2; //kilobytes
194 }
195
196 if(number>1024*1024)
197 {
198 format=3; //megabytes
199 }
200
201 if(number>1024*1024*1024)
202 {
203 format=4; //gigabytes (dude, what are you doing?)
204 }
205 }
206
207 switch(format)
208 {
209 case 1: //bytes
210 sprintf(num_str,"%db",number);
211 break;
212
213 case 2: //kilobytes
214 sprintf(num_str,"%.2fk",float(number)/1024);
215 break;
216
217 case 3: //megabytes
218 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
219 break;
220
221 case 4: //gigabytes
222 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
223 break;
224
225 default:
226 exit(1);
227 break;
228 }
229
230 return num_str;
231 }
232
233 462 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
234 {
235 static char num_str1[40];
236 static char num_str2[40];
237 static char num_str[80];
238
239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format1==-1) //auto
240 {
241 462 format1=1; //bytes
242
243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number1>1024)
244 {
245 462 format1=2; //kilobytes
246 462 }
247
248
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 132 times.
462 if(number1>1024*1024)
249 {
250 132 format1=3; //megabytes
251 132 }
252
253
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number1>1024*1024*1024)
254 {
255 format1=4; //gigabytes (dude, what are you doing?)
256 }
257 462 }
258
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format2==-1) //auto
260 {
261 462 format2=1; //bytes
262
263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number2>1024)
264 {
265 462 format2=2; //kilobytes
266 462 }
267
268
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 429 times.
462 if(number2>1024*1024)
269 {
270 429 format2=3; //megabytes
271 429 }
272
273
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number2>1024*1024*1024)
274 {
275 format2=4; //gigabytes (dude, what are you doing?)
276 }
277 462 }
278
279
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
462 switch(format1)
280 {
281 case 1: //bytes
282 sprintf(num_str1,"%db",number1);
283 break;
284
285 case 2: //kilobytes
286 330 sprintf(num_str1,"%.2fk",float(number1)/1024);
287 330 break;
288
289 case 3: //megabytes
290 132 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
291 132 break;
292
293 case 4: //gigabytes
294 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
295 break;
296
297 default:
298 exit(1);
299 break;
300 }
301
302
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 429 times.
✗ Branch 4 not taken.
462 switch(format2)
303 {
304 case 1: //bytes
305 sprintf(num_str2,"%db",number2);
306 break;
307
308 case 2: //kilobytes
309 33 sprintf(num_str2,"%.2fk",float(number2)/1024);
310 33 break;
311
312 case 3: //megabytes
313 429 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
314 429 break;
315
316 case 4: //gigabytes
317 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
318 break;
319
320 default:
321 exit(1);
322 break;
323 }
324
325 462 sprintf(num_str, "%s/%s", num_str1, num_str2);
326 462 return num_str;
327 }
328
329 char *ordinal(int32_t num)
330 {
331 static const char *ending[4] = {"st","nd","rd","th"};
332 static char ord_str[8];
333
334 char *end;
335 int32_t t=(num%100)/10;
336 int32_t n=num%10;
337
338 if(n>=1 && n<4 && t!=1)
339 end = (char *)ending[n-1];
340 else
341 end = (char *)ending[3];
342
343 sprintf(ord_str,"%d%s",num%10000,end);
344 return ord_str;
345 }
346
347 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
348 {
349 int32_t ret;
350 *version=0;
351 *build=0;
352 byte temp_map_count=map_count;
353 byte temp_midi_flags[MIDIFLAGS_SIZE];
354 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
355
356 zquestheader tempheader;
357
358 if(!f)
359 {
360 return qe_invalid;
361 }
362
363 ret=readheader(f, &tempheader, true);
364
365 if(ret)
366 {
367 return ret;
368 }
369
370 map_count=temp_map_count;
371 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
372 *version=tempheader.zelda_version;
373 *build=tempheader.build;
374 return 0;
375 }
376
377
378 bool find_section(PACKFILE *f, int32_t section_id_requested)
379 {
380
381 if(!f)
382 {
383 return false;
384 }
385
386 int32_t section_id_read;
387 bool catchup=false;
388 word dummy;
389 byte tempbyte;
390 char tempbuf[65536];
391
392
393 switch(section_id_requested)
394 {
395 case ID_RULES:
396 case ID_STRINGS:
397 case ID_MISC:
398 case ID_TILES:
399 case ID_COMBOS:
400 case ID_CSETS:
401 case ID_MAPS:
402 case ID_DMAPS:
403 case ID_DOORS:
404 case ID_ITEMS:
405 case ID_WEAPONS:
406 case ID_COLORS:
407 case ID_ICONS:
408 case ID_INITDATA:
409 case ID_GUYS:
410 case ID_MIDIS:
411 case ID_CHEATS:
412 break;
413
414 default:
415 al_trace("Bad section requested!\n");
416 return false;
417 break;
418 }
419
420 dword section_size;
421
422 //section id
423 if(!p_mgetl(&section_id_read,f,true))
424 {
425 return false;
426 }
427
428 while(!pack_feof(f))
429 {
430 switch(section_id_read)
431 {
432 case ID_RULES:
433 case ID_STRINGS:
434 case ID_MISC:
435 case ID_TILES:
436 case ID_COMBOS:
437 case ID_CSETS:
438 case ID_MAPS:
439 case ID_DMAPS:
440 case ID_DOORS:
441 case ID_ITEMS:
442 case ID_WEAPONS:
443 case ID_COLORS:
444 case ID_ICONS:
445 case ID_INITDATA:
446 case ID_GUYS:
447 case ID_MIDIS:
448 case ID_CHEATS:
449 catchup=false;
450 break;
451
452 default:
453 break;
454 }
455
456
457 while(catchup)
458 {
459 //section id
460 section_id_read=(section_id_read<<8);
461
462 if(!p_getc(&tempbyte,f,true))
463 {
464 return false;
465 }
466
467 section_id_read+=tempbyte;
468 }
469
470 if(section_id_read==section_id_requested)
471 {
472 return true;
473 }
474 else
475 {
476 //section version info
477 if(!p_igetw(&dummy,f,true))
478 {
479 return false;
480 }
481
482 if(!p_igetw(&dummy,f,true))
483 {
484 return false;
485 }
486
487 //section size
488 if(!p_igetl(&section_size,f,true))
489 {
490 return false;
491 }
492
493 //pack_fseek(f, section_size);
494 while(section_size>65535)
495 {
496 pfread(tempbuf,65535,f,true);
497 tempbuf[65535]=0;
498 section_size-=65535;
499 }
500
501 if(section_size>0)
502 {
503 pfread(tempbuf,section_size,f,true);
504 tempbuf[section_size]=0;
505 }
506 }
507
508 //section id
509 if(!p_mgetl(&section_id_read,f,true))
510 {
511 return false;
512 }
513 }
514
515 return false;
516 }
517
518
519
520
521
522 bool valid_zqt(PACKFILE *f)
523 {
524
525 //word tiles_used;
526 //word combos_used;
527 //open the file
528 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
529 if(!f)
530 return false;
531
532 //for now, everything else is valid
533 return true;
534
535 /*int16_t version;
536 byte build;
537
538 //read the version and make sure it worked
539 if(!p_igetw(&version,f,true))
540 {
541 goto error;
542 }
543
544 //read the build and make sure it worked
545 if(!p_getc(&build,f,true))
546 goto error;
547
548 //read the tile info and make sure it worked
549 if(!p_igetw(&tiles_used,f,true))
550 {
551 goto error;
552 }
553
554 for (int32_t i=0; i<tiles_used; i++)
555 {
556 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the combo info and make sure it worked
563 if(!p_igetw(&combos_used,f,true))
564 {
565 goto error;
566 }
567 for (int32_t i=0; i<combos_used; i++)
568 {
569 if(!pfread(trashbuf,sizeof(newcombo),f,true))
570 {
571 goto error;
572 }
573 }
574
575 //read the palette info and make sure it worked
576 for (int32_t i=0; i<48; i++)
577 {
578 if(!pfread(trashbuf,newpdTOTAL,f,true))
579 {
580 goto error;
581 }
582 }
583 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
584 {
585 goto error;
586 }
587 for (int32_t i=0; i<MAXLEVELS; i++)
588 {
589 if(!pfread(trashbuf,PALNAMESIZE,f,true))
590 {
591 goto error;
592 }
593 }
594
595 //read the sprite info and make sure it worked
596 for (int32_t i=0; i<MAXITEMS; i++)
597 {
598 if(!pfread(trashbuf,sizeof(itemdata),f,true))
599 {
600 goto error;
601 }
602 }
603
604 for (int32_t i=0; i<MAXWPNS; i++)
605 {
606 if(!pfread(trashbuf,sizeof(wpndata),f,true))
607 {
608 goto error;
609 }
610 }
611
612 //read the triforce pieces info and make sure it worked
613 for (int32_t i=0; i<8; ++i)
614 {
615 if(!p_getc(&trashbuf,f,true))
616 {
617 goto error;
618 }
619 }
620
621
622
623 //read the game icons info and make sure it worked
624 for (int32_t i=0; i<4; ++i)
625 {
626 if(!p_igetw(&trashbuf,f,true))
627 {
628 goto error;
629 }
630 }
631
632 //read the misc colors info and map styles info and make sure it worked
633 if(!pfread(trashbuf,sizeof(zcolors),f,true))
634 {
635 goto error;
636 }
637
638 //read the template screens and make sure it worked
639 byte num_maps;
640 if(!p_getc(&num_maps,f,true))
641 {
642 goto error;
643 }
644 for (int32_t i=0; i<TEMPLATES; i++)
645 {
646 if(!pfread(trashbuf,sizeof(mapscr),f,true))
647 {
648 goto error;
649 }
650 }
651 if (num_maps>1) //dungeon templates
652 {
653 for (int32_t i=0; i<TEMPLATES; i++)
654 {
655 if(!pfread(trashbuf,sizeof(mapscr),f,true))
656 {
657 goto error;
658 }
659 }
660 }
661
662 //yay! it worked! close the file and say everything was ok.
663 pack_fclose(f);
664 return true;
665
666 error:
667 pack_fclose(f);
668 return false;*/
669 }
670
671 bool valid_zqt(const char *filename)
672 {
673 PACKFILE *f=NULL;
674 bool isvalid;
675 int32_t error;
676 f=open_quest_file(&error, filename, false);
677
678 if(!f)
679 {
680 // setPackfilePassword(NULL);
681 return false;
682 }
683
684 isvalid=valid_zqt(f);
685
686 // setPackfilePassword(NULL);
687 return isvalid;
688 }
689
690 /*
691 .qst file history
692
693 .qst files have always been compressed using allegro's packfiles.
694
695 At some point, an encoding layer was added. The two layers look like this:
696
697 1) The top layer is from us. See decode_file_007.
698 [0-24] Preamble "Zelda Classic Quest File"
699 [25-28] Initial decoding seed value.
700 [29-X] Allegro-encoded payload (AKA "packed" file)
701 [last 4] Checksum
702
703 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
704 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
705 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
706 The oldest quests skip the password part.
707
708 Simply, the job of this function is to peel away the top layer.
709
710 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
711 in opening and saving files. There is no version field, so they decryption key is
712 found via trial-by-error (very slow!)
713
714 There are other file types of interest:
715 - .zqt: quest template files, skips top-layer encryption pass
716 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
717 - .qu?: same as above. automated backup files
718 - .qb?: same as above. automated backup files
719 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
720
721 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
722 files are now "slh!.AG ZC Enhanced Quest File".
723 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
724 */
725 108 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
726 {
727 #ifdef __EMSCRIPTEN__
728 if (em_is_lazy_file(filename))
729 {
730 em_fetch_file(filename);
731 }
732 #endif
733
734 // Note: although this is primarily for loading .qst files, it can also handle all of the
735 // file types mentioned in the comment above. No need to be told if the file being loaded
736 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
737 108 bool top_layer_compressed = false;
738 108 bool compressed = false;
739 108 bool encrypted = false;
740
741 // Input files may or may not include a top layer, which may or may not be compressed.
742 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
743 // with an allegro packfile password (longtan).
744 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
745 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
746 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
747
748 108 bool id_came_from_compressed_file = false;
749 108 const char* packfile_password = "";
750 char id[31];
751 108 id[0] = '\0';
752 108 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
753
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 10 times.
108 if (!pf)
754 10 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
755
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3 times.
108 if (pf)
756 {
757 105 id_came_from_compressed_file = true;
758
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if (!pack_fread(id, sizeof(id), pf))
759 {
760 pack_fclose(pf);
761 Z_message("Unable to read header string\n");
762 return nullptr;
763 }
764 105 pack_fclose(pf);
765 105 }
766 else
767 {
768 3 FILE* f = fopen(filename, "rb");
769
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!fread(id, sizeof(char), sizeof(id), f))
770 {
771 fclose(f);
772 Z_message("Unable to read header string\n");
773 return nullptr;
774 }
775 3 fclose(f);
776 }
777
778
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
108 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
779 {
780 // The given file is already just the bottom layer - nothing more to do.
781 // There's no way to rewind a packfile, so just open it again.
782 98 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
783 }
784
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 else if (strstr(id, ENC_STR))
785 {
786 10 top_layer_compressed = id_came_from_compressed_file;
787 10 compressed = true;
788 10 encrypted = true;
789 10 }
790 else
791 {
792 // Unexpected, this is going to fail some header check later.
793 }
794
795 // Everything below here is legacy code - recently saved quest files will have
796 // returned by now.
797
798 char tmpfilename[L_tmpnam];
799 10 temp_name(tmpfilename);
800 char percent_done[30];
801 10 int32_t current_method=0;
802
803 PACKFILE *f;
804 10 const char *passwd= encrypted ? datapwd : "";
805
806 // oldquest flag is set when an unencrypted qst file is suspected.
807 10 bool oldquest = false;
808 int32_t ret;
809
810
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(show_progress)
811 {
812 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
813 }
814
815 10 box_out("Loading Quest: ");
816 10 al_trace("Trying to do strncasecmp() when loading a quest\n");
817 10 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
818 10 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
819
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
820 {
821 10 box_out(filename);
822 10 }
823 else
824 {
825 box_out("new quest"); // Or whatever
826 }
827 10 box_out("...");
828 10 box_eol();
829 10 box_eol();
830
831
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(encrypted)
832 {
833 10 box_out("Decrypting...");
834 10 box_save_x();
835 10 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
836
837
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(ret)
838 {
839 switch(ret)
840 {
841 case 1:
842 box_out("error.");
843 box_eol();
844 box_end(true);
845 *open_error=qe_notfound;
846 return NULL;
847
848 case 2:
849 box_out("error.");
850 box_eol();
851 box_end(true);
852 *open_error=qe_internal;
853 return NULL;
854 // be sure not to delete tmpfilename now...
855 }
856
857 if(ret==5) //old encryption?
858 {
859 current_method++;
860 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
861 box_out(percent_done);
862 box_load_x();
863 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
864 }
865
866 if(ret==5) //old encryption?
867 {
868 current_method++;
869 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
870 box_out(percent_done);
871 box_load_x();
872 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
873 }
874
875 if(ret==5) //old encryption?
876 {
877 current_method++;
878 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
879 box_out(percent_done);
880 box_load_x();
881 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
882 }
883
884 if(ret==5) //old encryption?
885 {
886 current_method++;
887 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
888 box_out(percent_done);
889 box_load_x();
890 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
891 }
892
893 if(ret)
894 {
895 oldquest = true;
896 passwd="";
897 }
898 }
899
900 10 box_out("okay.");
901 10 box_eol();
902 10 }
903 else
904 {
905 oldquest = true;
906 }
907
908 10 box_out("Opening...");
909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
910
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!f)
911 {
912 if((compressed==1)&&(errno==EDOM))
913 {
914 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
915 }
916
917 if(!f)
918 {
919 if(!oldquest)
920 {
921 delete_file(tmpfilename);
922 }
923 box_out("error.");
924 box_eol();
925 box_end(true);
926 *open_error=qe_invalid;
927 return NULL;
928 }
929 }
930
931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!oldquest)
932 {
933 10 delete_file(tmpfilename);
934 10 }
935
936 10 box_out("okay.");
937 10 box_eol();
938
939 10 return f;
940 108 }
941
942 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
943 {
944 char *filename;
945 PACKFILE *f=NULL;
946 int32_t open_error=0;
947
948 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
949 strcat(qstdat_string,"#NESQST_NEW_QST");
950 if(Header->templatepath[0]==0)
951 {
952 filename=(char *)malloc(2048);
953 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
954 strcpy(filename, qstdat_string);
955 }
956 else
957 {
958 filename=Header->templatepath;
959 }
960
961 f=open_quest_file(&open_error, filename, false);
962
963 if(Header->templatepath[0]==0)
964 {
965 free(filename);
966 }
967
968 if(!f)
969 {
970 return NULL;
971 }
972
973 if(validate)
974 {
975 if(!valid_zqt(f))
976 {
977 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
978 pack_fclose(f);
979 return NULL;
980 }
981 }
982
983 return f;
984 }
985
986 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
987 {
988 combosread=false;
989 mapsread=false;
990 fixffcs=false;
991
992 switch(section_id)
993 {
994 case ID_RULES:
995 case ID_STRINGS:
996 case ID_MISC:
997 case ID_TILES:
998 case ID_COMBOS:
999 case ID_CSETS:
1000 case ID_MAPS:
1001 case ID_DMAPS:
1002 case ID_DOORS:
1003 case ID_ITEMS:
1004 case ID_WEAPONS:
1005 case ID_COLORS:
1006 case ID_ICONS:
1007 case ID_INITDATA:
1008 case ID_GUYS:
1009 case ID_MIDIS:
1010 case ID_CHEATS:
1011 case ID_ITEMDROPSETS:
1012 case ID_FAVORITES:
1013 break;
1014
1015 default:
1016 return false;
1017 break;
1018 }
1019
1020 int32_t ret;
1021 word version, build;
1022 PACKFILE *f=NULL;
1023
1024 char deletefilename[1024];
1025 deletefilename[0]=0;
1026
1027 //why is this here?
1028 /*
1029 if(colordata==NULL)
1030 return false;
1031 */
1032
1033 //setPackfilePassword(datapwd);
1034 f=open_quest_template(Header, deletefilename, validate);
1035
1036 if(!f) //no file, nothing to delete
1037 {
1038 // setPackfilePassword(NULL);
1039 return false;
1040 }
1041
1042 ret=get_version_and_build(f, &version, &build);
1043
1044 if(ret||(version==0))
1045 {
1046 pack_fclose(f);
1047
1048 if(deletefilename[0])
1049 {
1050 delete_file(deletefilename);
1051 }
1052
1053 // setPackfilePassword(NULL);
1054 return false;
1055 }
1056
1057 if(!find_section(f, section_id))
1058 {
1059 al_trace("Can't find section!\n");
1060 pack_fclose(f);
1061
1062 if(deletefilename[0])
1063 {
1064 delete_file(deletefilename);
1065 }
1066
1067 //setPackfilePassword(NULL);
1068 return false;
1069 }
1070
1071 switch(section_id)
1072 {
1073 case ID_RULES:
1074 //rules
1075 ret=readrules(f, Header, true);
1076 break;
1077
1078 case ID_STRINGS:
1079 //strings
1080 ret=readstrings(f, Header, true);
1081 break;
1082
1083 case ID_MISC:
1084 //misc data
1085 ret=readmisc(f, Header, Misc, true);
1086 break;
1087
1088 case ID_TILES:
1089 //tiles
1090 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1091 break;
1092
1093 case ID_COMBOS:
1094 //combos
1095 clear_combos();
1096 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1097 combosread=true;
1098 break;
1099
1100 case ID_COMBOALIASES:
1101 //combos
1102 ret=readcomboaliases(f, Header, version, build, true);
1103 break;
1104
1105 case ID_CSETS:
1106 //color data
1107 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1108 break;
1109
1110 case ID_MAPS:
1111 //maps
1112 ret=readmaps(f, Header, true);
1113 mapsread=true;
1114 break;
1115
1116 case ID_DMAPS:
1117 //dmaps
1118 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1119 break;
1120
1121 case ID_DOORS:
1122 //door combo sets
1123 ret=readdoorcombosets(f, Header, true);
1124 break;
1125
1126 case ID_ITEMS:
1127 //items
1128 ret=readitems(f, version, build, true);
1129 break;
1130
1131 case ID_WEAPONS:
1132 //weapons
1133 ret=readweapons(f, Header, true);
1134 break;
1135
1136 case ID_COLORS:
1137 //misc. colors
1138 ret=readmisccolors(f, Header, Misc, true);
1139 break;
1140
1141 case ID_ICONS:
1142 //game icons
1143 ret=readgameicons(f, Header, Misc, true);
1144 break;
1145
1146 case ID_INITDATA:
1147 //initialization data
1148 ret=readinitdata(f, Header, true);
1149 break;
1150
1151 case ID_GUYS:
1152 //guys
1153 ret=readguys(f, Header, true);
1154 break;
1155
1156 case ID_MIDIS:
1157 //midis
1158 ret=readtunes(f, Header, tunes, true);
1159 break;
1160
1161 case ID_CHEATS:
1162 //cheat codes
1163 ret=readcheatcodes(f, Header, true);
1164 break;
1165
1166 case ID_ITEMDROPSETS:
1167 //item drop sets
1168 // Why is this one commented out?
1169 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1170 break;
1171
1172 case ID_FAVORITES:
1173 // favorite combos and aliases
1174 ret=readfavorites(f, version, build, true);
1175 break;
1176
1177 default:
1178 ret=-1;
1179 break;
1180 }
1181
1182 pack_fclose(f);
1183
1184 if(deletefilename[0])
1185 {
1186 delete_file(deletefilename);
1187 }
1188
1189 //setPackfilePassword(NULL);
1190 if(!ret)
1191 {
1192 return true;
1193 }
1194
1195 return false;
1196 }
1197
1198 bool init_tiles(bool validate, zquestheader *Header)
1199 {
1200 return init_section(Header, ID_TILES, NULL, NULL, validate);
1201 }
1202
1203 bool init_combos(bool validate, zquestheader *Header)
1204 {
1205 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1206 }
1207
1208 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1209 {
1210 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1211 }
1212
1213 108 void init_spritelists()
1214 {
1215
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
108 if(FFCore.quest_format[vZelda] < 0x255)
1216 {
1217 84 guys.setMax(255);
1218 84 items.setMax(255);
1219 84 Ewpns.setMax(255);
1220 84 Lwpns.setMax(255);
1221 84 Sitems.setMax(255);
1222 84 chainlinks.setMax(255);
1223 84 decorations.setMax(255);
1224 84 particles.setMax(255);
1225 84 }
1226 else
1227 {
1228 24 guys.setMax(255);
1229 24 items.setMax(255);
1230 24 Ewpns.setMax(255);
1231 24 Lwpns.setMax(255);
1232 24 Sitems.setMax(255);
1233 24 chainlinks.setMax(255);
1234 24 decorations.setMax(255);
1235 24 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1236 }
1237 108 }
1238
1239 33 bool reset_items(bool validate, zquestheader *Header)
1240 {
1241 33 bool ret = true;
1242
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (get_app_id() == App::zquest)
1243 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1244
1245
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8448 times.
8481 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1246
1247 33 return ret;
1248 }
1249
1250 bool reset_guys()
1251 {
1252 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1253 init_guys(V_GUYS);
1254 return true;
1255 }
1256
1257 bool reset_wpns(bool validate, zquestheader *Header)
1258 {
1259 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1260
1261 for(int32_t i=0; i<WPNCNT; i++)
1262 reset_weaponname(i);
1263
1264 return ret;
1265 }
1266
1267 bool reset_mapstyles(bool validate, miscQdata *Misc)
1268 {
1269 Misc->colors.blueframe_tile = 20044;
1270 Misc->colors.blueframe_cset = 0;
1271 Misc->colors.triforce_tile = 23461;
1272 Misc->colors.triforce_cset = 1;
1273 Misc->colors.triframe_tile = 18752;
1274 Misc->colors.triframe_cset = 1;
1275 Misc->colors.overworld_map_tile = 16990;
1276 Misc->colors.overworld_map_cset = 2;
1277 Misc->colors.HCpieces_tile = 21160;
1278 Misc->colors.HCpieces_cset = 8;
1279 Misc->colors.dungeon_map_tile = 19651;
1280 Misc->colors.dungeon_map_cset = 8;
1281 return true;
1282 }
1283
1284 bool reset_doorcombosets(bool validate, zquestheader *Header)
1285 {
1286 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1287 }
1288
1289 33 int32_t get_qst_buffers()
1290 {
1291 33 memrequested+=(sizeof(mapscr)*MAPSCRS);
1292 33 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1293 33 TheMaps.resize(MAPSCRS);
1294
1295
2/2
✓ Branch 0 taken 4488 times.
✓ Branch 1 taken 33 times.
4521 for(int32_t i(0); i<MAPSCRS; i++)
1296 4488 TheMaps[i].zero_memory();
1297
1298 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1299 33 Z_message("OK\n"); // Allocating map buffer...
1300
1301 33 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1302 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1303
1304
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1305 return 0;
1306
1307 33 Z_message("OK\n");
1308
1309 // Allocating space for all 65535 strings uses up 10.62MB...
1310 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1311 // (Shoelace's "Hero of Dreams" uses 1415.)
1312 // So let's be a bit generous and allow 4096 initially.
1313 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1314 // I tested it and it worked without flaw on 6/6/11. - L.
1315 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1316 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1317 // See https://discord.com/channels/876899628556091432/992984989073416242
1318 33 msg_strings_size = 8192;
1319 33 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1320 33 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1321
1322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 MsgStrings = new MsgStr[msg_strings_size];
1323
1324 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1325
2/2
✓ Branch 0 taken 270336 times.
✓ Branch 1 taken 33 times.
270369 for(auto q = 0; q < msg_strings_size; ++q)
1326 {
1327 270336 MsgStrings[q].clear();
1328 270336 }
1329 33 Z_message("OK\n"); // Allocating string buffer...
1330
1331 33 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1332 33 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1333
1334
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1335 return 0;
1336
1337 33 Z_message("OK\n"); // Allocating door combo buffer...
1338
1339 33 memrequested+=(sizeof(dmap)*MAXDMAPS);
1340 33 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1341
1342
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1343 return 0;
1344
1345 33 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1346 33 Z_message("OK\n"); // Allocating dmap buffer...
1347
1348 33 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1349 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1350
1351
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1352 return 0;
1353
1354 33 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1355 33 Z_message("OK\n"); // Allocating combo buffer...
1356
1357 33 memrequested+=(psTOTAL255);
1358 33 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1359
1360
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1361 return 0;
1362
1363 33 Z_message("OK\n"); // Allocating color data buffer...
1364
1365 33 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1366 33 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1367
1368 33 free_newtilebuf();
1369
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1370 return 0;
1371
1372 33 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1373 //Z_message("Performed memset on tiles\n");
1374 33 clear_tiles(newtilebuf);
1375 //Z_message("Performed clear_tiles()\n");
1376 33 Z_message("OK\n"); // Allocating tile buffer...
1377
1378
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(is_zquest())
1379 {
1380 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1381 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1382
1383 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1384 return 0;
1385
1386 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1387 clear_tiles(grabtilebuf);
1388 Z_message("OK\n"); // Allocating tile grab buffer...
1389 }
1390
1391 33 memrequested+=(100000);
1392 33 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1393
1394
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((trashbuf=(byte*)malloc(100000))==NULL)
1395 return 0;
1396
1397 33 Z_message("OK\n"); // Allocating trash buffer...
1398
1399 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1400 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1401 // fixed by ensuring there's actually itemdata there.
1402 // If you change this, be sure to update del_qst_buffers, too.
1403
1404 33 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1405 33 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1406
1407
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1408 return 0;
1409
1410 33 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1411 33 itemsbuf++;
1412 33 Z_message("OK\n"); // Allocating item buffer...
1413
1414 33 memrequested+=(sizeof(wpndata)*MAXWPNS);
1415 33 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1416
1417
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1418 return 0;
1419
1420 33 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1421 33 Z_message("OK\n"); // Allocating weapon buffer...
1422
1423 33 memrequested+=(sizeof(guydata)*MAXGUYS);
1424 33 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1425
1426
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1427 return 0;
1428
1429 33 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1430 33 Z_message("OK\n"); // Allocating guy buffer...
1431
1432 33 memrequested+=(sizeof(comboclass)*cMAX);
1433 33 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1434
1435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1436 return 0;
1437
1438 33 Z_message("OK\n"); // Allocating combo class buffer...
1439
1440 33 return 1;
1441 33 }
1442
1443
1444 33 void free_newtilebuf()
1445 {
1446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(newtilebuf)
1447 {
1448 for(int32_t i=0; i<NEWMAXTILES; i++)
1449 if(newtilebuf[i].data)
1450 free(newtilebuf[i].data);
1451
1452 free(newtilebuf);
1453 newtilebuf = 0;
1454 }
1455 33 }
1456
1457 void free_grabtilebuf()
1458 {
1459 if(is_zquest())
1460 {
1461 if(grabtilebuf)
1462 {
1463 for(int32_t i=0; i<NEWMAXTILES; i++)
1464 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1465
1466 free(grabtilebuf);
1467 grabtilebuf = 0;
1468 }
1469 }
1470 }
1471
1472 void del_qst_buffers()
1473 {
1474 al_trace("Cleaning maps. \n");
1475
1476 if(ZCMaps) free(ZCMaps);
1477
1478 if(MsgStrings) delete[] MsgStrings;
1479
1480 if(DoorComboSets) free(DoorComboSets);
1481
1482 if(DMaps) free(DMaps);
1483
1484 if(combobuf) free(combobuf);
1485
1486 if(colordata) free(colordata);
1487
1488 al_trace("Cleaning tile buffers. \n");
1489 free_newtilebuf();
1490 free_grabtilebuf();
1491
1492 al_trace("Cleaning misc. \n");
1493
1494 if(trashbuf) free(trashbuf);
1495
1496 // See get_qst_buffers
1497 if(itemsbuf)
1498 {
1499 itemsbuf--;
1500 free(itemsbuf);
1501 }
1502
1503 if(wpnsbuf) free(wpnsbuf);
1504
1505 if(guysbuf) free(guysbuf);
1506
1507 if(combo_class_buf) free(combo_class_buf);
1508 }
1509
1510 4 bool init_palnames()
1511 {
1512 // if(palnames==NULL)
1513 // return false;
1514
1515
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1516 {
1517
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1518 {
1519 case 0:
1520 4 sprintf(palnames[x],"Overworld");
1521 4 break;
1522
1523 case 10:
1524 4 sprintf(palnames[x],"Caves");
1525 4 break;
1526
1527 case 11:
1528 4 sprintf(palnames[x],"Passageways");
1529 4 break;
1530
1531 default:
1532 2036 sprintf(palnames[x],"%c",0);
1533 2036 break;
1534 }
1535 2048 }
1536
1537 4 return true;
1538 }
1539
1540 21322 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1541 {
1542 void *p;
1543
1544
1/2
✓ Branch 0 taken 21322 times.
✗ Branch 1 not taken.
21322 p = _AL_MALLOC(MAX(size, alloc_size));
1545
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21322 times.
21322 if(!p)
1547 {
1548 return NULL;
1549 }
1550
1551
1/2
✓ Branch 0 taken 21322 times.
✗ Branch 1 not taken.
21322 if(!pfread(p,size,f,keepdata))
1552 {
1553 _AL_FREE(p);
1554 return NULL;
1555 }
1556
1557
1/2
✓ Branch 0 taken 21322 times.
✗ Branch 1 not taken.
21322 if(pack_ferror(f))
1558 {
1559 _AL_FREE(p);
1560 return NULL;
1561 }
1562
1563 21322 return p;
1564 21322 }
1565
1566 /* read_midi:
1567 * Reads MIDI data from a datafile (this is not the same thing as the
1568 * standard midi file format).
1569 */
1570
1571 1867 static MIDI *read_midi(PACKFILE *f, bool)
1572 {
1573 MIDI *m;
1574 int32_t c;
1575 1867 int16_t divisions=0;
1576 1867 int32_t len=0;
1577
1578 1867 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1579
1580
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!m)
1581 {
1582 return NULL;
1583 }
1584
1585
2/2
✓ Branch 0 taken 59744 times.
✓ Branch 1 taken 1867 times.
61611 for(c=0; c<MIDI_TRACKS; c++)
1586 {
1587 59744 m->track[c].len = 0;
1588 59744 m->track[c].data = NULL;
1589 59744 }
1590
1591 1867 p_mgetw(&divisions,f,true);
1592 1867 m->divisions=divisions;
1593
1594
2/2
✓ Branch 0 taken 59744 times.
✓ Branch 1 taken 1867 times.
61611 for(c=0; c<MIDI_TRACKS; c++)
1595 {
1596 59744 p_mgetl(&len,f,true);
1597 59744 m->track[c].len=len;
1598
1599
2/2
✓ Branch 0 taken 38422 times.
✓ Branch 1 taken 21322 times.
59744 if(m->track[c].len > 0)
1600 {
1601 21322 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1602
1603
1/2
✓ Branch 0 taken 21322 times.
✗ Branch 1 not taken.
21322 if(!m->track[c].data)
1604 {
1605 destroy_midi(m);
1606 return NULL;
1607 }
1608 21322 }
1609 59744 }
1610
1611 LOCK_DATA(m, sizeof(MIDI));
1612
1613
2/2
✓ Branch 0 taken 59744 times.
✓ Branch 1 taken 1867 times.
61611 for(c=0; c<MIDI_TRACKS; c++)
1614 {
1615
2/2
✓ Branch 0 taken 21322 times.
✓ Branch 1 taken 38422 times.
59744 if(m->track[c].data)
1616 {
1617 LOCK_DATA(m->track[c].data, m->track[c].len);
1618 21322 }
1619 59744 }
1620
1621 1867 return m;
1622 1867 }
1623
1624 void clear_combo(int32_t i)
1625 {
1626 combobuf[i].clear();
1627 }
1628
1629 void clear_combos()
1630 {
1631 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1632 clear_combo(tmpcounter);
1633 }
1634
1635 void pack_combos()
1636 {
1637 int32_t di = 0;
1638
1639 for(int32_t si=0; si<1024; si+=2)
1640 combobuf[di++] = combobuf[si];
1641
1642 for(; di<1024; di++)
1643 clear_combo(di);
1644 }
1645
1646 108 void reset_tunes(zctune *tune)
1647 {
1648
2/2
✓ Branch 0 taken 27216 times.
✓ Branch 1 taken 108 times.
27324 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1649 {
1650 27216 tune[i].reset();
1651 27216 }
1652 108 }
1653
1654
1655 /*void reset_midi(zcmidi_ *m)
1656 {
1657 m->title[0]=0;
1658 m->loop=1;
1659 m->volume=144;
1660 m->start=0;
1661 m->loop_start=-1;
1662 m->loop_end=-1;
1663 if(m->midi)
1664 {
1665 destroy_midi(m->midi);
1666 }
1667 m->midi=NULL;
1668 }
1669
1670
1671 void reset_midis(zcmidi_ *m)
1672 {
1673 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1674 {
1675 reset_midi(m+i);
1676 }
1677 }
1678 */
1679
1680 void reset_scr(int32_t scr)
1681 {
1682 /*
1683 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1684 for(unsigned i=0; i<sizeof(mapscr); i++)
1685 *(di++) = 0;
1686 TheMaps[scr].valid=mVERSION;
1687 */
1688
1689 TheMaps[scr].zero_memory();
1690 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1691
1692 for(int32_t i=0; i<6; i++)
1693 {
1694 //these will be uncommented later
1695 //TheMaps[scr].layerxsize[i]=16;
1696 //TheMaps[scr].layerysize[i]=11;
1697 TheMaps[scr].layeropacity[i]=255;
1698 }
1699
1700 TheMaps[scr].valid=mVERSION;
1701
1702 }
1703
1704 /* For reference:
1705
1706 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1707 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1708 */
1709
1710 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1711 {
1712
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1713 {
1714
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1715 {
1716
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1717 {
1718
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1719 {
1720 1968 return false;
1721 }
1722
1723
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1724 {
1725 return false;
1726 }
1727
1728
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1729 {
1730 return false;
1731 }
1732
1733
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1734 {
1735 return false;
1736 }
1737 58104 }
1738
1739
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1740 {
1741 return false;
1742 }
1743
1744
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1745 {
1746 return false;
1747 }
1748
1749
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1750 {
1751 return false;
1752 }
1753
1754
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1755 {
1756 return false;
1757 }
1758 87156 }
1759
1760
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1761 {
1762
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1763 {
1764 return false;
1765 }
1766
1767
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1768 {
1769 return false;
1770 }
1771
1772
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1773 {
1774 return false;
1775 }
1776
1777
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1778 {
1779 return false;
1780 }
1781
1782
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1783 {
1784 return false;
1785 }
1786 3228 }
1787
1788
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1789 {
1790
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1791 {
1792 return false;
1793 }
1794
1795
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1796 {
1797 return false;
1798 }
1799
1800
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1801 {
1802 return false;
1803 }
1804
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1806 {
1807 return false;
1808 }
1809 4842 }
1810
1811
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1812 {
1813 return false;
1814 }
1815
1816
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1817 {
1818 return false;
1819 }
1820 14526 }
1821
1822 1614 return true;
1823 3582 }
1824
1825 int32_t doortranslations_u[9][4]=
1826 {
1827 {37,38,53,54},
1828 {37,38,39,40},
1829 {37,38,55,56},
1830 {37,38,39,40},
1831 {37,38,53,54},
1832 {37,38,53,54},
1833 {37,38,53,54},
1834 {7,8,23,24},
1835 {7,8,41,42}
1836 };
1837
1838 int32_t doortranslations_d[9][4]=
1839 {
1840 {117,118,133,134},
1841 {135,136,133,134},
1842 {119,120,133,134},
1843 {135,136,133,134},
1844 {117,118,133,134},
1845 {117,118,133,134},
1846 {117,118,133,134},
1847 {151,152,167,168},
1848 {137,138,167,168},
1849 };
1850
1851 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1852 int32_t doortranslations_l[9][6]=
1853 {
1854 {66,67,82,83,98,99},
1855 {66,68,82,84,98,100},
1856 {66,69,82,85,98,101},
1857 {66,68,82,84,98,100},
1858 {66,67,82,83,98,99},
1859 {66,67,82,83,98,99},
1860 {66,67,82,83,98,99},
1861 {64,65,80,81,96,97},
1862 {64,65,80,114,96,97},
1863 };
1864
1865 int32_t doortranslations_r[9][6]=
1866 {
1867
1868 {76,77,92,93,108,109},
1869 {75,77,91,93,107,109},
1870 {74,77,90,93,106,109},
1871 {75,77,91,93,107,109},
1872 {76,77,92,93,108,109},
1873 {76,77,92,93,108,109},
1874 {76,77,92,93,108,109},
1875 {78,79,94,95,110,111},
1876 {78,79,125,95,110,111},
1877 };
1878
1879 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1880 {
1881 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1882 }
1883
1884 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1885 {
1886 //these are here to bypass compiler warnings about unused arguments
1887 308180 map=map;
1888 308180 scr=scr;
1889 308180 pos=pos;
1890
1891 //what does this function do?
1892 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1893 308180 return 2;
1894 }
1895
1896 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1897 {
1898
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1899 {
1900 5450 return 0;
1901 }
1902
1903 DoorComboSet tempdcs;
1904 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1905
1906 //up
1907
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1908 {
1909
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1910 {
1911 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1912 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1913 58392 }
1914 14598 }
1915
1916 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1917 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1918 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1919 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1920 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1921 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1922
1923 //down
1924
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1925 {
1926
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1927 {
1928 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1929 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1930 58392 }
1931 14598 }
1932
1933 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1934
1935 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1936 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1937 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1938 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1939 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1940
1941 //left
1942 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1943
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1944 {
1945
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1946 {
1947 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1948 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1949 87588 }
1950 14598 }
1951
1952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1953 {
1954 if((j!=2)&&(j!=3))
1955 {
1956 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1957 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1958 }
1959 }
1960
1961 1622 tempdcs.bombdoorcombo_l[0]=0;
1962 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1963 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1964 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1965 1622 tempdcs.bombdoorcombo_l[2]=0;
1966 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1967 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1968 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1969
1970 //right
1971
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1972 {
1973
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1974 {
1975 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1976 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1977 87588 }
1978 14598 }
1979
1980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1981 {
1982 if((j!=2)&&(j!=3))
1983 {
1984 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1985 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1986 }
1987 }
1988
1989 1622 tempdcs.bombdoorcombo_r[0]=0;
1990 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1991 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1992 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1993 1622 tempdcs.bombdoorcombo_r[2]=0;
1994 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1995 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1996 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1997
1998 int32_t k;
1999
2000
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2001 {
2002
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2003 {
2004 1614 break;
2005 }
2006 1968 }
2007
2008
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2009 {
2010 8 DoorComboSets[k]=tempdcs;
2011 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2012 8 ++door_combo_set_count;
2013 8 }
2014
2015 1622 return k;
2016 /*
2017 doorcombo_u[9][4];
2018 doorcset_u[9][4];
2019 doorcombo_d[9][4];
2020 doorcset_d[9][4];
2021 doorcombo_l[9][6];
2022 doorcset_l[9][6];
2023 doorcombo_r[9][6];
2024 doorcset_r[9][6];
2025 bombdoorcombo_u[2];
2026 bombdoorcset_u[2];
2027 bombdoorcombo_d[2];
2028 bombdoorcset_d[2];
2029 bombdoorcombo_l[3];
2030 bombdoorcset_l[3];
2031 bombdoorcombo_r[3];
2032 bombdoorcset_r[3];
2033 walkthroughcombo[4];
2034 walkthroughcset[4];
2035 */
2036 7072 }
2037
2038 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2039 {
2040 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2041 }
2042
2043 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2044 {
2045
2046 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2047 }
2048
2049 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2050 {
2051 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2052 }
2053
2054
2055 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2056 {
2057 char temp_pwd[30];
2058 9 memset(temp_pwd,0,30);
2059
2060
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2061 {
2062 9 memcpy(temp_pwd,encrypted_pwd,30);
2063 9 temp_pwd[29]=0;
2064
2065
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2066 {
2067 270 temp_pwd[i] -= pwdkey;
2068 270 int32_t t=pwdkey>>15;
2069 270 pwdkey = (pwdkey<<1)+t;
2070 270 }
2071 9 }
2072
2073 9 memcpy(pwd,temp_pwd,30);
2074 9 }
2075
2076
2077 86 bool devpwd()
2078 {
2079 #ifdef _DEBUG
2080 return true;
2081 #endif
2082 86 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2083 }
2084 bool check_questpwd(zquestheader *Header, char *pwd)
2085 {
2086 #if DEVLEVEL > 3
2087 return true;
2088 #endif
2089
2090 if (devpwd()) return true;
2091 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2092 cvs_MD5Context ctx;
2093 uint8_t md5sum[16];
2094
2095 cvs_MD5Init(&ctx);
2096 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2097 cvs_MD5Final(md5sum, &ctx);
2098
2099 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2100 }
2101
2102 101 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2103 {
2104 101 zprint2("\n");
2105 101 zprint2("[ZQUEST CREATOR METADATA]\n");
2106
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(qst_num < moduledata.max_quest_files)
2107 zprint2("Loading module quest %d\n", qst_num+1);
2108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(path) zprint2("Loading '%s'\n", path);
2109
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
101 if ( tempheader.new_version_id_main > 0 )
2110 {
2111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(tempheader.new_version_id_fourth > 0)
2112 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2113 tempheader.new_version_id_main,tempheader.new_version_id_second,
2114 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2115 97 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2116 97 tempheader.new_version_id_main,tempheader.new_version_id_second,
2117 97 tempheader.new_version_id_third);
2118 97 }
2119 else
2120 {
2121
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2122 {
2123 case 0x255:
2124 {
2125 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2126 break;
2127 }
2128 case 0x254:
2129 {
2130 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2131 break;
2132 }
2133 case 0x250:
2134 {
2135 switch(tempheader.build)
2136 {
2137 case 19:
2138 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2139 case 20:
2140 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2141 case 21:
2142 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2143 case 22:
2144 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2145 case 23:
2146 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2147 case 24:
2148 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2149 case 25:
2150 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2151 case 26:
2152 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2153 case 27:
2154 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2155 case 28:
2156 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2157 case 29:
2158 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2159 case 30:
2160 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2161 case 31:
2162 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2163 case 32:
2164 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2165 case 33:
2166 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2167 default:
2168 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2169
2170 }
2171 break;
2172 }
2173
2174 case 0x211:
2175 {
2176 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2177 }
2178 case 0x210:
2179 {
2180 zprint2("Last saved in ZQuest Version: 2.10.x");
2181 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2182 break;
2183 }
2184 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2185 case 0x193:
2186 {
2187 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2188 }
2189 case 0x192:
2190 {
2191 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2192 }
2193 case 0x190:
2194 {
2195 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2196 }
2197 case 0x184:
2198 {
2199 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2200 }
2201 case 0x183:
2202 {
2203 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2204 }
2205 case 0x180:
2206 {
2207 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2208 }
2209 default:
2210 {
2211 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2212 }
2213 */
2214 }
2215 }
2216
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
101 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2217 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2218 84 else zprint2("\n");
2219
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2220
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2221
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2222
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2223
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 97 times.
101 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2224
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2225 101 zprint2("\n");
2226 101 }
2227
2228 108 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2229 {
2230 int32_t dummy;
2231 zquestheader tempheader;
2232 char dummybuf[80];
2233 byte temp_map_count;
2234 byte temp_midi_flags[MIDIFLAGS_SIZE];
2235 word version;
2236 char temp_pwd[30], temp_pwd2[30];
2237 int16_t temp_pwdkey;
2238 cvs_MD5Context ctx;
2239 108 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2240 108 memset(&tempheader, 0, sizeof(tempheader));
2241 108 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2242
2243
2244
2245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2246 {
2247 Z_message("Unable to read header string\n");
2248 return qe_invalid;
2249 }
2250
2251 // check header
2252
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2253 {
2254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2255 {
2256 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2257 return qe_invalid;
2258 }
2259 4 }
2260
2261 108 int32_t templatepath_len=0;
2262
2263 108 tempheader.external_zinfo = false;
2264 108 read_zinfo = false;
2265
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2266 {
2267 byte padding;
2268
2269
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2270 {
2271 return qe_invalid;
2272 }
2273
2274
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2275 {
2276 return qe_invalid;
2277 }
2278
2279 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2280
2281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2282 {
2283 return qe_version;
2284 }
2285
2286 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2287
2288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2289 {
2290 return qe_invalid;
2291 }
2292
2293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2294 {
2295 return qe_obsolete;
2296 }
2297
2298
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2299 {
2300 return qe_invalid;
2301 }
2302
2303
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2309
2310
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 4 FFCore.quest_format[qMapCount] = temp_map_count;
2321
2322
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2328 {
2329 return qe_invalid;
2330 }
2331
2332
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2333 {
2334 return qe_invalid;
2335 }
2336
2337
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2338 {
2339 return qe_invalid;
2340 }
2341
2342
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2343 {
2344 return qe_invalid;
2345 }
2346
2347
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2348 {
2349 return qe_invalid;
2350 }
2351
2352
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2353 {
2354 return qe_invalid;
2355 }
2356
2357
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2358 {
2359 return qe_invalid;
2360 }
2361
2362
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2363 {
2364 return qe_invalid;
2365 }
2366 // These fields are expected to end in null bytes!
2367 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2368
2369
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2370 {
2371 return qe_invalid;
2372 }
2373 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2374
2375
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2376 {
2377 return qe_invalid;
2378 }
2379
2380
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2381 {
2382 return qe_invalid;
2383 }
2384
2385
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2386 {
2387 return qe_invalid;
2388 }
2389
2390 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2391 4 cvs_MD5Init(&ctx);
2392 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2393 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2394
2395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2396 {
2397 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2398 // Not anymore...
2399 memset(tempheader.minver,0,17);
2400 tempheader.build=0;
2401 tempheader.use_keyfile=0;
2402 memset(tempheader.old_foo, 0, 9);
2403 }
2404 else
2405 {
2406
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2407 {
2408 return qe_invalid;
2409 }
2410
2411
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2412 {
2413 return qe_invalid;
2414 }
2415
2416 4 FFCore.quest_format[vBuild] = tempheader.build;
2417
2418
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2424 {
2425 return qe_invalid;
2426 }
2427 } // starting at minver
2428
2429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2430 {
2431 memset(&quest_rules[4],0,16); // word rules3..rules10
2432 }
2433 else
2434 {
2435
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2436 {
2437 return qe_invalid; // starting at rules3
2438 }
2439
2440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2441 {
2442 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2443 4 }
2444 }
2445
2446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2447 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2448 {
2449 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2450 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2451 4 }
2452
2453
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2454 {
2455 byte *mf=temp_midi_flags;
2456
2457 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2458 {
2459 mf=(byte*)dummybuf;
2460 }
2461
2462 if(!pfread(mf,32,f,true)) // read new header additions
2463 {
2464 return qe_invalid; // starting at foo2
2465 }
2466
2467 if(!pfread(dummybuf,18,f,true)) // read new header additions
2468 {
2469 return qe_invalid; // starting at foo2
2470 }
2471 }
2472
2473
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2474 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2475 {
2476 4 memset(tempheader.templatepath,0,2048);
2477 4 }
2478 else
2479 {
2480 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2481 {
2482 return qe_invalid;
2483 }
2484 }
2485
2486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2487 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2488 {
2489 4 tempheader.use_keyfile=0;
2490 4 }
2491 4 }
2492 else
2493 {
2494 //section id
2495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_mgetl(&dummy,f,true))
2496 {
2497 return qe_invalid;
2498 }
2499
2500 //section version info
2501
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&version,f,true))
2502 {
2503 return qe_invalid;
2504 }
2505
2506 104 FFCore.quest_format[vHeader] = version;
2507
2508
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
2509 {
2510 return qe_invalid;
2511 }
2512
2513 //section size
2514
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
2515 {
2516 return qe_invalid;
2517 }
2518
2519 //finally... section data
2520
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&tempheader.zelda_version,f,true))
2521 {
2522 return qe_invalid;
2523 }
2524
2525 104 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2526
2527 //do some quick checking...
2528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(tempheader.zelda_version > ZELDA_VERSION)
2529 {
2530 return qe_version;
2531 }
2532
2533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2534 {
2535 return qe_invalid;
2536 }
2537
2538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(bad_version(tempheader.zelda_version))
2539 {
2540 return qe_obsolete;
2541 }
2542
2543
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.build,f,true))
2544 {
2545 return qe_invalid;
2546 }
2547
2548 104 FFCore.quest_format[vBuild] = tempheader.build;
2549
2550
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(version<3)
2551 {
2552
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2553 {
2554 return qe_invalid;
2555 }
2556
2557
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2558 {
2559 return qe_invalid;
2560 }
2561
2562 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2563 5 cvs_MD5Init(&ctx);
2564 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2565 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2566 5 }
2567 else
2568 {
2569
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2570 {
2571 return qe_invalid;
2572 }
2573 }
2574
2575
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&tempheader.internal,f,true))
2576 {
2577 return qe_invalid;
2578 }
2579
2580
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.quest_number,f,true))
2581 {
2582 return qe_invalid;
2583 }
2584
2585 104 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2586
2587 104 size_t versz = version < 8 ? 9 : 16;
2588
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.version,versz,f,true))
2589 {
2590 return qe_invalid;
2591 }
2592
2593 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2594 //needs to be copied as char[9] or stored as a s.str
2595
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.minver,versz,f,true))
2596 {
2597 return qe_invalid;
2598 }
2599
2600 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2601
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2602 {
2603 return qe_invalid;
2604 }
2605 104 tempheader.title[sizeof(tempheader.title)-1] = 0;
2606
2607
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2608 {
2609 return qe_invalid;
2610 }
2611 104 tempheader.author[sizeof(tempheader.author)-1] = 0;
2612
2613
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.use_keyfile,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618 /*
2619 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2620 {
2621 return qe_invalid;
2622 }
2623 */
2624
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
2629
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(&dummybuf,4,f,true))
2630 {
2631 return qe_invalid;
2632 }
2633
2634
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2635 {
2636 return qe_invalid;
2637 }
2638
2639
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(dummybuf,14,f,true))
2640 {
2641 return qe_invalid;
2642 }
2643
2644 104 templatepath_len=sizeof(tempheader.templatepath);
2645
2646
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(version==1)
2647 {
2648 5 templatepath_len=280;
2649 5 }
2650
2651
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2652 {
2653 return qe_invalid;
2654 }
2655
2656
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_map_count,f,true))
2657 {
2658 return qe_invalid;
2659 }
2660
2661
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(version>=4)
2662 {
2663
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2664 {
2665 return qe_invalid;
2666 }
2667
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2668 {
2669 return qe_invalid;
2670 }
2671
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2672 {
2673 return qe_invalid;
2674 }
2675
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2676 {
2677 return qe_invalid;
2678 }
2679
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2680 {
2681 return qe_invalid;
2682 }
2683
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2684 {
2685 return qe_invalid;
2686 }
2687
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2688 {
2689 return qe_invalid;
2690 }
2691
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2692 {
2693 return qe_invalid;
2694 }
2695
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2696 {
2697 return qe_invalid;
2698 }
2699
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2700 {
2701 return qe_invalid;
2702 }
2703
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2704 {
2705 return qe_invalid;
2706 }
2707
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2708 {
2709 return qe_invalid;
2710 }
2711
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2712 {
2713 return qe_invalid;
2714 }
2715
2716
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.new_version_devsig,256,f,true))
2717 {
2718 return qe_invalid;
2719 }
2720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2721 strcpy(tempheader.new_version_devsig, "EmilyV99");
2722
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.new_version_compilername,256,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2727 {
2728 return qe_invalid;
2729 }
2730
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.product_name,1024,f,true))
2731 {
2732 return qe_invalid;
2733 }
2734
2735
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.compilerid,f,true))
2736 {
2737 return qe_invalid;
2738 }
2739
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2740 {
2741 return qe_invalid;
2742 }
2743
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2744 {
2745 return qe_invalid;
2746 }
2747
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2748 {
2749 return qe_invalid;
2750 }
2751
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2752 {
2753 return qe_invalid;
2754 }
2755
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.developerid,f,true))
2756 {
2757 return qe_invalid;
2758 }
2759
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2760 {
2761 return qe_invalid;
2762 }
2763
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.build_datestamp,256,f,true))
2764 {
2765 return qe_invalid;
2766 }
2767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!pfread(tempheader.build_timestamp,256,f,true))
2768 {
2769 return qe_invalid;
2770 }
2771 24 }
2772 else // <4
2773 {
2774 80 tempheader.new_version_id_main = 0;
2775 80 tempheader.new_version_id_second = 0;
2776 80 tempheader.new_version_id_third = 0;
2777 80 tempheader.new_version_id_fourth = 0;
2778 80 tempheader.new_version_id_alpha = 0;
2779 80 tempheader.new_version_id_beta = 0;
2780 80 tempheader.new_version_id_gamma = 0;
2781 80 tempheader.new_version_id_release = 0;
2782 80 tempheader.new_version_id_date_year = 0;
2783 80 tempheader.new_version_id_date_month = 0;
2784 80 tempheader.new_version_id_date_day = 0;
2785 80 tempheader.new_version_id_date_hour = 0;
2786 80 tempheader.new_version_id_date_minute = 0;
2787
2788 80 memset(tempheader.new_version_devsig, 0, 256);
2789 80 memset(tempheader.new_version_compilername, 0, 256);
2790 80 memset(tempheader.new_version_compilerversion, 0, 256);
2791 80 memset(tempheader.product_name, 0, 1024);
2792 80 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2793
2794 80 tempheader.compilerid = 0;
2795 80 tempheader.compilerversionnumber_first = 0;
2796 80 tempheader.compilerversionnumber_second = 0;
2797 80 tempheader.compilerversionnumber_third = 0;
2798 80 tempheader.compilerversionnumber_fourth = 0;
2799 80 tempheader.developerid = 0;
2800
2801 80 memset(tempheader.made_in_module_name, 0, 1024);
2802 80 memset(tempheader.build_datestamp, 0, 256);
2803 80 memset(tempheader.build_timestamp, 0, 256);
2804 }
2805
2806
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if ( version >= 5 )
2807 {
2808
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.build_timezone,6,f,true))
2809 {
2810 return qe_invalid;
2811 }
2812 24 }
2813 else // < 5
2814 {
2815 80 memset(tempheader.build_timezone, 0, 6);
2816 }
2817
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if ( version >= 6 )
2818 {
2819 byte b;
2820
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&b,f,true))
2821 {
2822 return qe_invalid;
2823 }
2824 24 tempheader.external_zinfo = b?true:false;
2825 24 read_zinfo = true;
2826 24 }
2827
2828
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(version >= 7)
2829 {
2830
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2831 {
2832 return qe_invalid;
2833 }
2834 24 }
2835 else
2836 {
2837 80 tempheader.new_version_is_nightly = false;
2838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(tempheader.zelda_version < 0x255)
2839 {
2840
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
80 switch(tempheader.zelda_version)
2841 {
2842 case 0x254:
2843 tempheader.new_version_id_main = 2;
2844 tempheader.new_version_id_second = 54;
2845 break;
2846 case 0x250:
2847
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 8 times.
✓ Branch 15 taken 1 times.
75 switch(tempheader.build)
2848 {
2849 case 19:
2850 tempheader.new_version_id_main = 2;
2851 tempheader.new_version_id_second = 50;
2852 tempheader.new_version_id_gamma = 1;
2853 break;
2854 case 20:
2855 tempheader.new_version_id_main = 2;
2856 tempheader.new_version_id_second = 50;
2857 tempheader.new_version_id_gamma = 2;
2858 break;
2859 case 21:
2860 tempheader.new_version_id_main = 2;
2861 tempheader.new_version_id_second = 50;
2862 tempheader.new_version_id_gamma = 3;
2863 break;
2864 case 22:
2865 tempheader.new_version_id_main = 2;
2866 tempheader.new_version_id_second = 50;
2867 tempheader.new_version_id_gamma = 4;
2868 break;
2869 case 23:
2870 tempheader.new_version_id_main = 2;
2871 tempheader.new_version_id_second = 50;
2872 tempheader.new_version_id_gamma = 5;
2873 break;
2874 case 24:
2875 22 tempheader.new_version_id_main = 2;
2876 22 tempheader.new_version_id_second = 50;
2877 22 tempheader.new_version_id_release = -1;
2878 22 break;
2879 case 25:
2880 tempheader.new_version_id_main = 2;
2881 tempheader.new_version_id_second = 50;
2882 tempheader.new_version_id_third = 1;
2883 tempheader.new_version_id_gamma = 1;
2884 break;
2885 case 26:
2886 tempheader.new_version_id_main = 2;
2887 tempheader.new_version_id_second = 50;
2888 tempheader.new_version_id_third = 1;
2889 tempheader.new_version_id_gamma = 2;
2890 break;
2891 case 27:
2892 tempheader.new_version_id_main = 2;
2893 tempheader.new_version_id_second = 50;
2894 tempheader.new_version_id_third = 1;
2895 tempheader.new_version_id_gamma = 3;
2896 break;
2897 case 28:
2898 5 tempheader.new_version_id_main = 2;
2899 5 tempheader.new_version_id_second = 50;
2900 5 tempheader.new_version_id_third = 1;
2901 5 tempheader.new_version_id_release = -1;
2902 5 break;
2903 case 29:
2904 24 tempheader.new_version_id_main = 2;
2905 24 tempheader.new_version_id_second = 50;
2906 24 tempheader.new_version_id_third = 2;
2907 24 tempheader.new_version_id_release = -1;
2908 24 break;
2909 case 30:
2910 tempheader.new_version_id_main = 2;
2911 tempheader.new_version_id_second = 50;
2912 tempheader.new_version_id_third = 3;
2913 tempheader.new_version_id_gamma = 1;
2914 break;
2915 case 31:
2916 15 tempheader.new_version_id_main = 2;
2917 15 tempheader.new_version_id_second = 53;
2918 15 tempheader.new_version_id_gamma = -1;
2919 15 break;
2920 case 32:
2921 8 tempheader.new_version_id_main = 2;
2922 8 tempheader.new_version_id_second = 53;
2923 8 tempheader.new_version_id_release = -1;
2924 8 break;
2925 case 33:
2926 1 tempheader.new_version_id_main = 2;
2927 1 tempheader.new_version_id_second = 53;
2928 1 tempheader.new_version_id_third = 1;
2929 1 break;
2930 }
2931 75 break;
2932
2933 case 0x211:
2934 tempheader.new_version_id_main = 2;
2935 tempheader.new_version_id_second = 11;
2936 tempheader.new_version_id_beta = tempheader.build;
2937 break;
2938 case 0x210:
2939 5 tempheader.new_version_id_main = 2;
2940 5 tempheader.new_version_id_second = 10;
2941 5 tempheader.new_version_id_beta = tempheader.build;
2942 5 break;
2943 }
2944 80 }
2945 }
2946
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(printmetadata || __isZQuest)
2947 {
2948 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2949 }
2950 }
2951
2952 //{ Version Warning
2953 108 int32_t vercmp = tempheader.compareVer();
2954 108 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2955 108 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2956
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
132 if(vercmp > 0 || (!vercmp &&
2957
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 (astatecmp > 0 || (!astatecmp &&
2958 24 avercmp > 0))))
2959 {
2960 bool r = true;
2961 if(loadquest_report)
2962 {
2963 enter_sys_pal();
2964 AlertDialog("Quest saved in newer version",
2965 "This quest was last saved in a newer version of ZQuest."
2966 " Attempting to load this quest may not work correctly; to"
2967 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2968 "\n\nWould you like to continue loading anyway? (Not recommended)",
2969 [&](bool ret,bool)
2970 {
2971 r = ret;
2972 }).show();
2973 exit_sys_pal();
2974 }
2975 if(!r)
2976 return qe_silenterr;
2977 }
2978
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 else if(tempheader.compareDate() > 0)
2979 {
2980 bool r = true;
2981 if(loadquest_report)
2982 {
2983 enter_sys_pal();
2984 AlertDialog("Quest saved in newer build",
2985 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2986 " issues loading in this build."
2987 "\n{}"
2988 "\n\nWould you like to continue loading anyway?",
2989 tempheader.getVerCmpStr()),
2990 [&](bool ret,bool)
2991 {
2992 r = ret;
2993 }).show();
2994 exit_sys_pal();
2995 }
2996 if(!r)
2997 return qe_silenterr;
2998 }
2999 //}
3000
3001 108 read_ext_zinfo = tempheader.external_zinfo;
3002
3003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
3004 {
3005 108 memcpy(Header, &tempheader, sizeof(tempheader));
3006 108 map_count=temp_map_count;
3007 108 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3008 108 }
3009
3010 108 return 0;
3011 108 }
3012
3013 110 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3014 {
3015 int32_t dummy;
3016 zquestheader tempheader;
3017 110 word s_version=0;
3018 110 dword compatrule_version=0;
3019
3020 110 memcpy(&tempheader, Header, sizeof(tempheader));
3021
3022
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 104 times.
110 if(tempheader.zelda_version >= 0x193)
3023 {
3024 //section version info
3025
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
3026 {
3027 return qe_invalid;
3028 }
3029
3030 104 FFCore.quest_format[vRules] = s_version;
3031
3032
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
3033 {
3034 return qe_invalid;
3035 }
3036
3037
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if(s_version > 16)
3038 {
3039
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&compatrule_version,f,true))
3040 {
3041 return qe_invalid;
3042 }
3043 24 }
3044 104 FFCore.quest_format[vCompatRule] = compatrule_version;
3045
3046 //section size
3047
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
3048 {
3049 return qe_invalid;
3050 }
3051
3052
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if ( s_version < 15 )
3053 {
3054 //finally... section data
3055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3056 {
3057 return qe_invalid;
3058 }
3059 80 }
3060 else
3061 {
3062
3063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3064 {
3065 return qe_invalid;
3066 }
3067
3068 }
3069 104 }
3070
3071 //al_trace("Rules version %d\n", s_version);
3072 //{ bunch of compat stuff
3073 110 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3074
3075
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(s_version<2)
3076 {
3077 9 set_bit(quest_rules,14,0);
3078 9 set_bit(quest_rules,27,0);
3079 9 set_bit(quest_rules,28,0);
3080 9 set_bit(quest_rules,29,0);
3081 9 set_bit(quest_rules,30,0);
3082 9 set_bit(quest_rules,32,0);
3083 9 set_bit(quest_rules,36,0);
3084 9 set_bit(quest_rules,49,0);
3085 9 set_bit(quest_rules,50,0);
3086 9 set_bit(quest_rules,51,0);
3087 9 set_bit(quest_rules,68,0);
3088 9 set_bit(quest_rules,75,0);
3089 9 set_bit(quest_rules,76,0);
3090 9 set_bit(quest_rules,98,0);
3091 9 set_bit(quest_rules,110,0);
3092 9 set_bit(quest_rules,113,0);
3093 9 set_bit(quest_rules,116,0);
3094 9 set_bit(quest_rules,102,0);
3095 9 set_bit(quest_rules,132,0);
3096 9 }
3097
3098 //Now, do any updates...
3099
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3100 {
3101 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3102 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3103 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3104 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3105 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3106 13 }
3107
3108
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3109 {
3110 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3111 8 }
3112
3113
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3114 {
3115 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3116 8 }
3117
3118
5/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3119 {
3120 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3121 8 }
3122
3123
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version <= 0x210)
3124 {
3125 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3126 9 }
3127
3128
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(tempheader.zelda_version == 0x210)
3129 {
3130 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3131 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3132 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3133 5 }
3134
3135
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version <= 0x210)
3136 {
3137 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3138 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3139 9 }
3140
3141 //might not be correct
3142
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4 times.
110 if(tempheader.zelda_version < 0x210)
3143 {
3144 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3145 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3146 4 }
3147
3148
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version < 0x211)
3149 {
3150 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3151 9 }
3152
3153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3154 {
3155 set_bit(quest_rules, qr_192b163_WARP,1);
3156 }
3157
3158
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 5 times.
110 if(tempheader.zelda_version == 0x210)
3159 {
3160 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3161 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3162 5 }
3163
3164
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3165 {
3166 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3167 13 }
3168
3169
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
110 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3170 {
3171 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3172 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3173 13 }
3174
3175
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 9 times.
110 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3176 {
3177 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3178 9 }
3179
3180
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 22 times.
110 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3181 {
3182 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3183 22 }
3184
3185
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 77 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3186 {
3187 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3188 13 }
3189
3190
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 77 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3191 {
3192 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3193 13 }
3194
3195
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 55 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3196 {
3197 35 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3198 35 }
3199
3200
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 55 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3201 {
3202 35 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3203 35 }
3204
3205 //Bombchu fix.
3206
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 75 times.
110 if(tempheader.zelda_version == 0x250)
3207 {
3208
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 22 times.
75 if ( tempheader.build == 24 ) //2.50.0
3209 {
3210 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3211 22 }
3212
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if ( tempheader.build == 28 ) //2.50.1
3213 {
3214 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3215 5 }
3216
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 24 times.
75 if ( tempheader.build == 29 ) //2.50.2
3217 {
3218 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3219 24 }
3220
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( tempheader.build == 30 ) //2.50.3RC1
3221 {
3222 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3223 }
3224 75 }
3225
3226
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 50 times.
110 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3227 {
3228 // qr_OFFSETEWPNCOLLISIONFIX
3229 // All 'official' quests need this disabled.
3230 // All 2.10 and lower quests need this enabled to preseve compatability.
3231 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3232
3233 //~Gleeok
3234 36 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3235
3236 // Broke in build 695
3237
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
36 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3238 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3239 36 }
3240
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 4 times.
110 if (tempheader.zelda_version <= 0x190)
3241 {
3242 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3243 4 }
3244
9/10
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 24 times.
110 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3245 {
3246 85 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3247 85 }
3248
3249
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3250 {
3251 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3252 9 }
3253
3254
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3255 {
3256 84 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3257 84 }
3258
3259
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( tempheader.zelda_version < 0x250 )
3260 {
3261 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3262 9 }
3263
3264
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 3)
3265 {
3266 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3267 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3268 9 }
3269
3270
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<4)
3271 {
3272 9 set_bit(quest_rules,10,0);
3273 9 }
3274
3275
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<5)
3276 {
3277 9 set_bit(quest_rules,27,0);
3278 9 }
3279
3280
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<6)
3281 {
3282 9 set_bit(quest_rules,46,0);
3283 9 }
3284
3285
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<7) // January 2008
3286 {
3287 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3288 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3289 9 }
3290
3291
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version<8)
3292 {
3293 9 set_bit(quest_rules, 12, 0);
3294 9 }
3295 else
3296 {
3297 99 set_bit(deprecated_rules, 12, 0);
3298 }
3299
3300
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<9) // October 2008
3301 {
3302 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3303 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3304 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3305 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3306 9 }
3307
3308
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<10) // December 2008
3309 {
3310 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3311 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3312 9 }
3313
3314
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<11) // April 2009
3315 {
3316 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3317 9 }
3318
3319
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<12) // December 2009
3320 {
3321 9 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3322 9 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3323 9 }
3324
3325 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3326
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 13)
3327 {
3328 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3329 9 }
3330
3331 // Not entirely sure this is the best place for this...
3332 //2.50.2 bitmap offset fix
3333 108 memset(extra_rules, 0, EXTRARULES_SIZE);
3334
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 48 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3335 {
3336 36 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3337 36 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3338 36 }
3339 //required because quest templates also used this bit, although
3340 //it never did anything, before. -Z
3341
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 75 times.
108 if ( tempheader.zelda_version == 0x250 )
3342 {
3343
5/6
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 36 times.
75 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3344 {
3345 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3346 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3347 39 }
3348 75 }
3349
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if ( tempheader.zelda_version == 0x254 )
3350 {
3351 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3352 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3353 }
3354
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
108 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3355 {
3356 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3357 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3358 }
3359 //optimise fast drawing for older versions.
3360
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3361 {
3362 84 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3363 84 }
3364 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3365 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3366 //older quests can set the rule by hand. We need a new qst.dat again.
3367
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3368 {
3369 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3370 }
3371
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3372 {
3373 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3374 }
3375
4/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3376 {
3377 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3378 }
3379
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if ( tempheader.zelda_version < 0x254 )
3380 {
3381 84 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3382 84 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3383 84 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3384 84 }
3385
3386 //item scripts continue to run
3387
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3388 {
3389 84 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3390 84 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3391 84 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3392 84 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3393 84 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3394 84 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3395 84 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3396 84 }
3397
3398
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3399 {
3400 84 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3401 84 }
3402
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3403 {
3404 84 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3405 84 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3406 84 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3407 84 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3408 84 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3409 84 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3410 84 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3411 84 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3412
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2 times.
84 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3413 {
3414 2 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3415 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3416 //Now they **do**, unless you disable that behaviour.
3417 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3418 //now enable the disable L/R item swap on load.
3419 2 }
3420
3421 84 }
3422
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3423 {
3424 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3425 84 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3426 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3427 //animations ending earlier than they should.
3428 84 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3429 //Enemies would ignore solidity on the top half of combos
3430 84 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3431 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3432 84 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3433 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3434 84 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3435 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3436 84 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3437 84 }
3438
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if ( tempheader.zelda_version < 0x255 )
3439 {
3440 84 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3441 84 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3442 84 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3443 84 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3444 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3445 84 }
3446
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3447 {
3448 84 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3449 84 }
3450
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3451 {
3452 84 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3453 84 }
3454
3455
3456
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3457 {
3458 84 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3459 84 }
3460
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3461 {
3462 84 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3463 84 }
3464
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3465 {
3466 84 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3467 84 }
3468
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3469 {
3470 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3471
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3472 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3473 84 }
3474
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3475 {
3476 84 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3477 84 }
3478
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3479 {
3480 84 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3481 84 }
3482
3483
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if ( tempheader.zelda_version < 0x254 )
3484 {
3485 84 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3486 84 }
3487 //Sideview spikes in 2.50.0
3488
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 53 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3489 {
3490 31 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3491 31 }
3492 //more 2.50 fixes -Z
3493
6/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 24 times.
108 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3494 {
3495 60 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3496 60 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3497 60 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3498 60 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3499 60 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3500
3501 60 }
3502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3503 {
3504 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3505 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3506 }
3507
3508
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(tempheader.zelda_version < 0x193)
3509 {
3510 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3511 4 }
3512
3513
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(tempheader.zelda_version < 0x255)
3514 {
3515 84 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3516 84 }
3517
3518
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3519 {
3520 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3521 9 }
3522
3523
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3524 {
3525 84 set_bit(quest_rules,qr_OLD_F6,1);
3526 84 }
3527
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3528 {
3529 84 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3530 84 }
3531
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3532 {
3533 84 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3534 84 }
3535
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3536 {
3537 84 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3538 84 }
3539 //}
3540
3541
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3542 84 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3543
3544
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 2) //Old CSet2 Handling
3545 84 set_bit(quest_rules,qr_OLDCS2,1);
3546
3547
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3548 84 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3549
3550
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3551 84 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3552
3553
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 75 times.
108 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3554 75 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3555
3556
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3557 84 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3558
3559
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3560 84 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3561
3562
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3563 84 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3564
3565
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 9)
3566 {
3567 //Hardcoded BS Patras
3568 84 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3569 //Hardcoded Patra Inner Eye offsets
3570 84 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3571 //Broken 'Big enemy' animation style
3572 84 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3573 //Broken Attribute 31/32
3574 84 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3575 84 }
3576
3577
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 10) //Shared candle use limits
3578 84 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3579
3580
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 11) //No cross-screen return points
3581 84 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3582
3583
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 12)
3584 {
3585 //Old fire trail duration
3586 84 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3587 //Old Intro String in Ganon Room Behavior
3588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3589 84 else set_bit(quest_rules,qr_GANONINTRO,1);
3590 84 }
3591
3592
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
108 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3593 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3594
3595
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 14) //Old Bridge Combo Behavior
3596 84 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3597
3598
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 15) //Broken Z3 Animation
3599 84 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3600
3601
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3602 84 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3603
3604
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 17)
3605 {
3606 //Old Quake/DrawYOffset behavior
3607 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3608 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3609 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3610 84 }
3611
3612
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 18)
3613 {
3614 //Broken DrawScreen Derivative Functions
3615 84 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3616 //Scrolling Cancels Charge
3617 84 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3618 84 }
3619
3620
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3621 84 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3622
3623
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 20)
3624 84 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3625
3626
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 21)
3627 {
3628 84 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3629 84 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3630 84 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3631 84 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3632 84 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3633 84 }
3634
3635
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 22)
3636 84 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3637
3638
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 23)
3639 84 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3640
3641
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 24)
3642 {
3643 84 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3644 84 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3645 84 }
3646
3647
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 25)
3648 {
3649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3650 84 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3651 84 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3652 84 }
3653
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 26)
3654 {
3655 84 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3656 84 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3657 84 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3658 84 }
3659
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3660 {
3661
2/2
✓ Branch 0 taken 25284 times.
✓ Branch 1 taken 84 times.
25368 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3662 25284 set_bit(quest_rules,q,0);
3663
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 84 times.
9492 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3664 9408 set_bit(quest_rules,q,0);
3665 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3666 84 }
3667
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 28)
3668 86 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3669
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 29)
3670 86 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3671
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 30)
3672 {
3673 86 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3674 86 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3675 86 }
3676
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 31)
3677 {
3678 86 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3679 86 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3680 86 }
3681
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 32)
3682 86 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3683
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(compatrule_version < 33)
3684 86 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3685
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 88 times.
108 if(compatrule_version < 34)
3686 {
3687 88 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3688 88 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3689 88 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3690 88 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3691 88 }
3692
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 89 times.
108 if(compatrule_version < 35)
3693 {
3694 // Leaving this commented for now, might need to enable later -Em
3695 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3696 89 }
3697
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 89 times.
108 if(compatrule_version < 36)
3698 89 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3699
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 37)
3700 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3701
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 38)
3702 99 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3703
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 39)
3704 99 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3705
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(compatrule_version < 40)
3706 99 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(compatrule_version < 41)
3708 108 set_bit(quest_rules,qr_BROKENHITBY,1);
3709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(compatrule_version < 42)
3710 108 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3711
3712 108 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3713
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if (s_version < 16)
3714 84 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3715
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
3717 108 memcpy(Header, &tempheader, sizeof(tempheader));
3718
3719 108 return 0;
3720 108 }
3721
3722 897832 void init_msgstr(MsgStr *str)
3723 {
3724 897832 str->s = "";
3725 897832 str->s.shrink_to_fit();
3726 897832 str->nextstring=0;
3727 897832 str->tile=0;
3728 897832 str->cset=0;
3729 897832 str->trans=false;
3730 897832 str->font=font_zfont;
3731 897832 str->y=32;
3732 897832 str->sfx=18;
3733 897832 str->listpos=0;
3734 897832 str->x=24;
3735 897832 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3736 897832 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3737 897832 str->hspace=0;
3738 897832 str->vspace=0;
3739 897832 str->stringflags=0;
3740 897832 str->margins[up] = 8;
3741 897832 str->margins[down] = 0;
3742 897832 str->margins[left] = 8;
3743 897832 str->margins[right] = 0;
3744 897832 str->portrait_tile = 0;
3745 897832 str->portrait_cset = 0;
3746 897832 str->portrait_x = 0;
3747 897832 str->portrait_y = 0;
3748 897832 str->portrait_tw = 1;
3749 897832 str->portrait_th = 1;
3750 897832 str->shadow_type = 0;
3751 897832 str->shadow_color = 0;
3752 897832 str->drawlayer = 6;
3753 897832 }
3754
3755 108 void init_msgstrings(int32_t start, int32_t end)
3756 {
3757
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(end <= start || end-start > msg_strings_size)
3758 return;
3759
3760
2/2
✓ Branch 0 taken 884736 times.
✓ Branch 1 taken 108 times.
884844 for(int32_t i=start; i<end; i++)
3761 {
3762 884736 init_msgstr(&MsgStrings[i]);
3763 884736 MsgStrings[i].listpos=i;
3764 884736 }
3765
3766
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(start==0)
3767 {
3768 108 MsgStrings[0].s = "(None)";
3769 108 MsgStrings[0].listpos = 0;
3770 108 }
3771 108 }
3772
3773 108 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3774 {
3775 108 MsgStr tempMsgString;
3776
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 init_msgstr(&tempMsgString);
3777
3778 108 word temp_msg_count=0;
3779 word temp_expansion[16];
3780 108 memset(temp_expansion, 0, 16*sizeof(word));
3781 108 char buf[8193] = {0};
3782
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version < 0x193)
3783 {
3784 byte tempbyte;
3785 4 int32_t strings_to_read=0;
3786
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3787
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3788 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3789 {
3790 4 strings_to_read=128;
3791 4 temp_msg_count=Header->old_str_count;
3792
3793 // Some sort of string count corruption seems to be common in old quests
3794
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3795 {
3796 temp_msg_count=128;
3797 }
3798 4 }
3799 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3800 {
3801 strings_to_read=255;
3802 temp_msg_count=Header->old_str_count;
3803 }
3804 else
3805 {
3806 if(!p_igetw(&temp_msg_count,f,true))
3807 {
3808 return qe_invalid;
3809 }
3810
3811 strings_to_read=temp_msg_count;
3812
3813 if(temp_msg_count >= msg_strings_size)
3814 {
3815 Z_message("Reallocating string buffer...\n");
3816
3817 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3818 // return qe_nomem;
3819
3820 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3821 delete[] MsgStrings;
3822 MsgStrings = new MsgStr[MAXMSGS];
3823 msg_strings_size = MAXMSGS;
3824 for(auto q = 0; q < msg_strings_size; ++q)
3825 {
3826 MsgStrings[q].clear();
3827 }
3828 }
3829 }
3830
3831 //reset the message strings
3832
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3833 {
3834
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3835 4 }
3836
3837
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3838 {
3839
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3840
3841
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3842 {
3843 return qe_invalid;
3844 }
3845
3846 512 buf[74] = '\0';
3847
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3848
3849
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3850 {
3851 return qe_invalid;
3852 }
3853
3854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3855 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3856 {
3857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3858
3859
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3860 {
3861 return qe_invalid;
3862 }
3863
3864
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3865 {
3866 return qe_invalid;
3867 }
3868 512 }
3869 else
3870 {
3871 if(!p_igetw(&tempMsgString.nextstring,f,true))
3872 {
3873 return qe_invalid;
3874 }
3875
3876 if(!pfread(temp_expansion,32,f,true))
3877 {
3878 return qe_invalid;
3879 }
3880 }
3881
3882
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3883 {
3884
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3885 512 }
3886 512 }
3887 4 }
3888 else
3889 {
3890 int32_t dummy_int;
3891 word s_version;
3892 word s_cversion;
3893
3894 //section version info
3895
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_version,f,true))
3896 {
3897 return qe_invalid;
3898 }
3899
3900 104 FFCore.quest_format[vStrings] = s_version;
3901
3902
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_cversion,f,true))
3903 {
3904 return qe_invalid;
3905 }
3906
3907 //al_trace("Strings version %d\n", s_version);
3908 //section size
3909
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetl(&dummy_int,f,true))
3910 {
3911 return qe_invalid;
3912 }
3913
3914 //finally... section data
3915
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&temp_msg_count,f,true))
3916 {
3917 return qe_invalid;
3918 }
3919
3920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(temp_msg_count >= msg_strings_size)
3921 {
3922 Z_message("Reallocating string buffer...\n");
3923
3924 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3925 // return qe_nomem;
3926 delete[] MsgStrings;
3927 MsgStrings = new MsgStr[MAXMSGS];
3928 msg_strings_size = MAXMSGS;
3929 for(auto q = 0; q < msg_strings_size; ++q)
3930 {
3931 MsgStrings[q].clear();
3932 }
3933 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3934 }
3935
3936 //reset the message strings
3937
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(keepdata)
3938 {
3939
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if(s_version < 7)
3940
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3941
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 init_msgstrings(0,msg_strings_size);
3942 104 }
3943
3944 104 int32_t string_length=(s_version<2)?73:145;
3945
3946
2/2
✓ Branch 0 taken 12476 times.
✓ Branch 1 taken 104 times.
12580 for(int32_t i=0; i<temp_msg_count; i++)
3947 {
3948
1/2
✓ Branch 0 taken 12476 times.
✗ Branch 1 not taken.
12476 init_msgstr(&tempMsgString);
3949
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 11612 times.
12476 if(s_version > 8)
3950 {
3951
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_igetl(&string_length,f,true))
3952 {
3953 return qe_invalid;
3954 }
3955 864 }
3956
2/2
✓ Branch 0 taken 12338 times.
✓ Branch 1 taken 138 times.
12476 if (string_length > 0)
3957 {
3958
2/4
✓ Branch 0 taken 12338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12338 times.
✗ Branch 3 not taken.
12338 if (!pfread(buf, string_length, f, true))
3959 {
3960 return qe_invalid;
3961 }
3962 12338 }
3963 else
3964 {
3965 138 buf[0] = 0;
3966 }
3967
3968
2/4
✓ Branch 0 taken 12476 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12476 times.
✗ Branch 3 not taken.
12476 if(!p_igetw(&tempMsgString.nextstring,f,true))
3969 {
3970 return qe_invalid;
3971 }
3972
3973
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7830 times.
12476 if(s_version<2)
3974 {
3975 4646 buf[72] = '\0';
3976
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
3977 4646 }
3978 else
3979 {
3980 // June 2008: A bug corrupted the last 4 chars of a string.
3981 // Discard these.
3982
1/2
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
7830 if(s_version<3)
3983 {
3984 for(int32_t j=140; j<144; j++)
3985 {
3986 buf[j] = '\0';
3987 }
3988 }
3989
1/2
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
7830 if(string_length > 8192) string_length = 8192;
3990 7830 buf[string_length]='\0'; //Force-terminate
3991
1/2
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
7830 tempMsgString.s = buf;
3992
3993
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 6966 times.
7830 if ( s_version >= 6 )
3994 {
3995
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_igetl(&tempMsgString.tile,f,true))
3996 {
3997 return qe_invalid;
3998 }
3999 864 }
4000 else
4001 {
4002
2/4
✓ Branch 0 taken 6966 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6966 times.
✗ Branch 3 not taken.
6966 if(!p_igetw(&tempMsgString.tile,f,true))
4003 {
4004 return qe_invalid;
4005 }
4006 }
4007
4008
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.cset,f,true))
4009 {
4010 return qe_invalid;
4011 }
4012
4013 byte dummy_char;
4014
4015
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4016 {
4017 return qe_invalid;
4018 }
4019
4020 7830 tempMsgString.trans=dummy_char!=0;
4021
4022
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.font,f,true))
4023 {
4024 return qe_invalid;
4025 }
4026
4027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7830 times.
7830 if(s_version < 5)
4028 {
4029 if(!p_getc(&tempMsgString.y,f,true))
4030 {
4031 return qe_invalid;
4032 }
4033 }
4034 else
4035 {
4036
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_igetw(&tempMsgString.x,f,true))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_igetw(&tempMsgString.y,f,true))
4042 {
4043 return qe_invalid;
4044 }
4045
4046
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_igetw(&tempMsgString.w,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050
4051
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_igetw(&tempMsgString.h,f,true))
4052 {
4053 return qe_invalid;
4054 }
4055
4056
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.hspace,f,true))
4057 {
4058 return qe_invalid;
4059 }
4060
4061
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.vspace,f,true))
4062 {
4063 return qe_invalid;
4064 }
4065
4066
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.stringflags,f,true))
4067 {
4068 return qe_invalid;
4069 }
4070 }
4071
4072
2/2
✓ Branch 0 taken 6966 times.
✓ Branch 1 taken 864 times.
7830 if(s_version >= 7)
4073 {
4074
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 3456 times.
4320 for(int32_t q = 0; q < 4; ++q)
4075 {
4076
2/4
✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3456 times.
✗ Branch 3 not taken.
3456 if(!p_getc(&tempMsgString.margins[q],f,true))
4077 {
4078 return qe_invalid;
4079 }
4080 3456 }
4081
4082
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4083 {
4084 return qe_invalid;
4085 }
4086
4087
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4088 {
4089 return qe_invalid;
4090 }
4091
4092
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.portrait_x,f,true))
4093 {
4094 return qe_invalid;
4095 }
4096
4097
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.portrait_y,f,true))
4098 {
4099 return qe_invalid;
4100 }
4101
4102
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4103 {
4104 return qe_invalid;
4105 }
4106
4107
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.portrait_th,f,true))
4108 {
4109 return qe_invalid;
4110 }
4111 864 }
4112
4113
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 6966 times.
7830 if(s_version >= 8)
4114 {
4115
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.shadow_type,f,true))
4116 {
4117 return qe_invalid;
4118 }
4119
4120
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
864 if(!p_getc(&tempMsgString.shadow_color,f,true))
4121 {
4122 return qe_invalid;
4123 }
4124 864 }
4125
4126
2/2
✓ Branch 0 taken 747 times.
✓ Branch 1 taken 7083 times.
7830 if(s_version >= 10)
4127 {
4128
2/4
✓ Branch 0 taken 747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 747 times.
✗ Branch 3 not taken.
747 if(!p_getc(&tempMsgString.drawlayer,f,true))
4129 {
4130 return qe_invalid;
4131 }
4132 747 }
4133
4134
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_getc(&tempMsgString.sfx,f,true))
4135 {
4136 return qe_invalid;
4137 }
4138
4139
1/2
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
7830 if(s_version>3)
4140 {
4141
2/4
✓ Branch 0 taken 7830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7830 times.
✗ Branch 3 not taken.
7830 if(!p_igetw(&tempMsgString.listpos,f,true))
4142 {
4143 return qe_invalid;
4144 }
4145 7830 }
4146 }
4147
4148
1/2
✓ Branch 0 taken 12476 times.
✗ Branch 1 not taken.
12476 if(keepdata==true)
4149 {
4150
1/2
✓ Branch 0 taken 12476 times.
✗ Branch 1 not taken.
12476 MsgStrings[i].copyAll(tempMsgString);
4151 12476 }
4152 12476 }
4153 }
4154
4155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
4156 {
4157 108 msg_count=temp_msg_count;
4158 108 }
4159
4160 108 return 0;
4161 108 }
4162
4163 108 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4164 {
4165
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
4166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4167 {
4168 4 return 0;
4169 }
4170
4171 104 word temp_door_combo_set_count=0;
4172 DoorComboSet tempDoorComboSet;
4173 word dummy_word;
4174 int32_t dummy_long;
4175 byte padding;
4176 104 int32_t s_version = 0;
4177
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4179 {
4180
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4181 {
4182 26624 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4183 26624 }
4184 104 }
4185
4186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(Header->zelda_version > 0x192)
4187 {
4188 //section version info
4189
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
4190 {
4191 return qe_invalid;
4192 }
4193
4194 104 FFCore.quest_format[vDoors] = s_version;
4195
4196 //al_trace("Door combo sets version %d\n", dummy_word);
4197
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy_word,f,true))
4198 {
4199 return qe_invalid;
4200 }
4201
4202 //section size
4203
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy_long,f,true))
4204 {
4205 return qe_invalid;
4206 }
4207 104 }
4208
4209 //finally... section data
4210
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_door_combo_set_count,f,true))
4211 {
4212 return qe_invalid;
4213 }
4214
4215
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 104 times.
891 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4216 {
4217 787 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4218
4219 //name
4220
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4221 {
4222 return qe_invalid;
4223 }
4224
4225
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(Header->zelda_version < 0x193)
4226 {
4227 if(!p_getc(&padding,f,true))
4228 {
4229 return qe_invalid;
4230 }
4231 }
4232
4233 //up door
4234
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4235 {
4236
2/2
✓ Branch 0 taken 28332 times.
✓ Branch 1 taken 7083 times.
35415 for(int32_t k=0; k<4; k++)
4237 {
4238
1/2
✓ Branch 0 taken 28332 times.
✗ Branch 1 not taken.
28332 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4239 {
4240 return qe_invalid;
4241 }
4242 28332 }
4243 7083 }
4244
4245
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4246 {
4247
2/2
✓ Branch 0 taken 28332 times.
✓ Branch 1 taken 7083 times.
35415 for(int32_t k=0; k<4; k++)
4248 {
4249
1/2
✓ Branch 0 taken 28332 times.
✗ Branch 1 not taken.
28332 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4250 {
4251 return qe_invalid;
4252 }
4253 28332 }
4254 7083 }
4255
4256 //down door
4257
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4258 {
4259
2/2
✓ Branch 0 taken 28332 times.
✓ Branch 1 taken 7083 times.
35415 for(int32_t k=0; k<4; k++)
4260 {
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28332 times.
28332 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4262 {
4263 return qe_invalid;
4264 }
4265 28332 }
4266 7083 }
4267
4268
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4269 {
4270
2/2
✓ Branch 0 taken 28332 times.
✓ Branch 1 taken 7083 times.
35415 for(int32_t k=0; k<4; k++)
4271 {
4272
1/2
✓ Branch 0 taken 28332 times.
✗ Branch 1 not taken.
28332 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4273 {
4274 return qe_invalid;
4275 }
4276 28332 }
4277 7083 }
4278
4279 //left door
4280
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4281 {
4282
2/2
✓ Branch 0 taken 42498 times.
✓ Branch 1 taken 7083 times.
49581 for(int32_t k=0; k<6; k++)
4283 {
4284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42498 times.
42498 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4285 {
4286 return qe_invalid;
4287 }
4288 42498 }
4289 7083 }
4290
4291
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4292 {
4293
2/2
✓ Branch 0 taken 42498 times.
✓ Branch 1 taken 7083 times.
49581 for(int32_t k=0; k<6; k++)
4294 {
4295
1/2
✓ Branch 0 taken 42498 times.
✗ Branch 1 not taken.
42498 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4296 {
4297 return qe_invalid;
4298 }
4299 42498 }
4300 7083 }
4301
4302 //right door
4303
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4304 {
4305
2/2
✓ Branch 0 taken 42498 times.
✓ Branch 1 taken 7083 times.
49581 for(int32_t k=0; k<6; k++)
4306 {
4307
1/2
✓ Branch 0 taken 42498 times.
✗ Branch 1 not taken.
42498 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4308 {
4309 return qe_invalid;
4310 }
4311 42498 }
4312 7083 }
4313
4314
2/2
✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 787 times.
7870 for(int32_t j=0; j<9; j++)
4315 {
4316
2/2
✓ Branch 0 taken 42498 times.
✓ Branch 1 taken 7083 times.
49581 for(int32_t k=0; k<6; k++)
4317 {
4318
1/2
✓ Branch 0 taken 42498 times.
✗ Branch 1 not taken.
42498 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4319 {
4320 return qe_invalid;
4321 }
4322 42498 }
4323 7083 }
4324
4325 //up bomb rubble
4326
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 787 times.
2361 for(int32_t j=0; j<2; j++)
4327 {
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1574 times.
1574 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4329 {
4330 return qe_invalid;
4331 }
4332 1574 }
4333
4334
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 787 times.
2361 for(int32_t j=0; j<2; j++)
4335 {
4336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1574 times.
1574 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4337 {
4338 return qe_invalid;
4339 }
4340 1574 }
4341
4342 //down bomb rubble
4343
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 787 times.
2361 for(int32_t j=0; j<2; j++)
4344 {
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1574 times.
1574 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4346 {
4347 return qe_invalid;
4348 }
4349 1574 }
4350
4351
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 787 times.
2361 for(int32_t j=0; j<2; j++)
4352 {
4353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1574 times.
1574 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4354 {
4355 return qe_invalid;
4356 }
4357 1574 }
4358
4359 //left bomb rubble
4360
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 787 times.
3148 for(int32_t j=0; j<3; j++)
4361 {
4362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
2361 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4363 {
4364 return qe_invalid;
4365 }
4366 2361 }
4367
4368
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 787 times.
3148 for(int32_t j=0; j<3; j++)
4369 {
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
2361 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4371 {
4372 return qe_invalid;
4373 }
4374 2361 }
4375
4376
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(Header->zelda_version < 0x193)
4377 {
4378 if(!p_getc(&padding,f,true))
4379 {
4380 return qe_invalid;
4381 }
4382
4383 }
4384
4385 //right bomb rubble
4386
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 787 times.
3148 for(int32_t j=0; j<3; j++)
4387 {
4388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
2361 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4389 {
4390 return qe_invalid;
4391 }
4392 2361 }
4393
4394
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 787 times.
3148 for(int32_t j=0; j<3; j++)
4395 {
4396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
2361 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4397 {
4398 return qe_invalid;
4399 }
4400 2361 }
4401
4402
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(Header->zelda_version < 0x193)
4403 {
4404 if(!p_getc(&padding,f,true))
4405 {
4406 return qe_invalid;
4407 }
4408 }
4409
4410 //walkthrough stuff
4411
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 787 times.
3935 for(int32_t j=0; j<4; j++)
4412 {
4413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4414 {
4415 return qe_invalid;
4416 }
4417 3148 }
4418
4419
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 787 times.
3935 for(int32_t j=0; j<4; j++)
4420 {
4421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4422 {
4423 return qe_invalid;
4424 }
4425 3148 }
4426
4427 //flags
4428
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 787 times.
2361 for(int32_t j=0; j<2; j++)
4429 {
4430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1574 times.
1574 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4431 {
4432 return qe_invalid;
4433 }
4434 1574 }
4435
4436
1/2
✓ Branch 0 taken 787 times.
✗ Branch 1 not taken.
787 if(Header->zelda_version < 0x193)
4437 {
4438 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4439 {
4440 return qe_invalid;
4441 }
4442 }
4443
4444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 787 times.
787 if(keepdata==true)
4445 {
4446 787 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4447 787 }
4448 787 }
4449
4450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4451 {
4452 104 door_combo_set_count=temp_door_combo_set_count;
4453 104 }
4454
4455 104 return 0;
4456 108 }
4457
4458 int32_t count_dmaps()
4459 {
4460 int32_t i=MAXDMAPS-1;
4461 bool found=false;
4462
4463 while(i>=0 && !found)
4464 {
4465 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4466 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4467 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4468 found=true;
4469
4470 for(int32_t j=0; j<8; j++)
4471 {
4472 if(DMaps[i].grid[j]!=0)
4473
4474 found=true;
4475 }
4476
4477 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4478 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4479 found=true;
4480
4481 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4482 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4483 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4484 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4485 found=true;
4486
4487 if(!found)
4488 {
4489 i--;
4490 }
4491 }
4492
4493 return i+1;
4494 }
4495
4496
4497 int32_t count_shops(miscQdata *Misc)
4498 {
4499 int32_t i=255,j;
4500 bool found=false;
4501
4502 while(i>=0 && !found)
4503 {
4504 j=2;
4505
4506 while(j>=0 && !found)
4507 {
4508 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4509 {
4510 found=true;
4511 }
4512 else
4513 {
4514 j--;
4515 }
4516 }
4517
4518 if(Misc->shop[i].name[0]!=0)
4519 {
4520 found=true;
4521 }
4522
4523 if(!found)
4524 {
4525 i--;
4526 }
4527 }
4528
4529 return i+1;
4530 }
4531
4532 int32_t count_infos(miscQdata *Misc)
4533 {
4534 int32_t i=255,j;
4535 bool found=false;
4536
4537 while(i>=0 && !found)
4538 {
4539 j=2;
4540
4541 while(j>=0 && !found)
4542 {
4543 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4544 {
4545 found=true;
4546 }
4547 else
4548 {
4549 j--;
4550 }
4551 }
4552
4553 if(Misc->info[i].name[0]!=0)
4554 {
4555 found=true;
4556 }
4557
4558 if(!found)
4559 {
4560 i--;
4561 }
4562 }
4563
4564 return i+1;
4565 }
4566
4567 int32_t count_warprings(miscQdata *Misc)
4568 {
4569 int32_t i=15,j;
4570 bool found=false;
4571
4572 while(i>=0 && !found)
4573 {
4574 j=7;
4575
4576 while(j>=0 && !found)
4577 {
4578 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4579 {
4580 found=true;
4581 }
4582 else
4583 {
4584 j--;
4585 }
4586 }
4587
4588 if(!found)
4589 {
4590 i--;
4591 }
4592 }
4593
4594 return i+1;
4595 }
4596
4597 int32_t count_palcycles(miscQdata *Misc)
4598 {
4599 int32_t i=255,j;
4600 bool found=false;
4601
4602 while(i>=0 && !found)
4603 {
4604 j=2;
4605
4606 while(j>=0 && !found)
4607 {
4608 if(Misc->cycles[i][j].count!=0)
4609 {
4610 found=true;
4611 }
4612 else
4613 {
4614 j--;
4615 }
4616 }
4617
4618 if(!found)
4619 {
4620 i--;
4621 }
4622 }
4623
4624 return i+1;
4625 }
4626
4627 201180 void clear_screen(mapscr *temp_scr)
4628 {
4629 201180 temp_scr->zero_memory();
4630 201180 }
4631
4632 108 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4633 {
4634 108 word dmapstoread=0;
4635 dmap tempDMap;
4636
4637 int32_t dummy;
4638 108 word s_version=0, s_cversion=0;
4639 byte padding;
4640
4641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
4642 {
4643
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<max_dmaps; i++)
4644 {
4645 55296 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4646 55296 sprintf(DMaps[start_dmap+i].title," ");
4647 55296 sprintf(DMaps[start_dmap+i].intro," ");
4648 55296 DMaps[start_dmap+i].type |= dmCAVE;
4649 55296 }
4650 108 }
4651
4652
3/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 4 times.
108 if(!Header || Header->zelda_version > 0x192)
4653 {
4654 //section version info
4655
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
4656 {
4657 return qe_invalid;
4658 }
4659
4660 104 FFCore.quest_format[vDMaps] = s_version;
4661
4662 //al_trace("DMaps version %d\n", s_version);
4663
4664
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
4665 {
4666 return qe_invalid;
4667 }
4668
4669 //section size
4670
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
4671 {
4672 return qe_invalid;
4673 }
4674
4675 //finally... section data
4676
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dmapstoread,f,true))
4677 {
4678 return qe_invalid;
4679 }
4680 104 }
4681 else
4682 {
4683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4684 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4685 {
4686 4 dmapstoread=32;
4687 4 }
4688 else if(s_version <= 4)
4689 {
4690 dmapstoread=OLDMAXDMAPS;
4691 }
4692 else
4693 {
4694 dmapstoread=MAXDMAPS;
4695 }
4696 }
4697
4698
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 dmapstoread=zc_min(dmapstoread, max_dmaps);
4699
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4700
4701
2/2
✓ Branch 0 taken 52096 times.
✓ Branch 1 taken 108 times.
52204 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4702 {
4703 52096 memset(&tempDMap,0,sizeof(dmap));
4704 52096 sprintf(tempDMap.title," ");
4705 52096 sprintf(tempDMap.intro," ");
4706
4707
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.map,f,keepdata))
4708 {
4709 return qe_invalid;
4710 }
4711
4712
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version <= 4)
4713 {
4714 byte tempbyte;
4715
4716
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4717 {
4718 return qe_invalid;
4719 }
4720
4721 1408 tempDMap.level=(word)tempbyte;
4722 1408 }
4723 else
4724 {
4725
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempDMap.level,f,keepdata))
4726 {
4727 return qe_invalid;
4728 }
4729 }
4730
4731
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.xoff,f,keepdata))
4732 {
4733 return qe_invalid;
4734 }
4735
4736
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.compass,f,keepdata))
4737 {
4738 return qe_invalid;
4739 }
4740
4741
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version > 8) // February 2009
4742 {
4743
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempDMap.color,f,true))
4744 {
4745 return qe_invalid;
4746 }
4747 50688 }
4748 else
4749 {
4750 byte tempbyte;
4751
4752
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4753 {
4754 return qe_invalid;
4755 }
4756
4757 1408 tempDMap.color = (word)tempbyte;
4758 }
4759
4760
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.midi,f,keepdata))
4761 {
4762 return qe_invalid;
4763 }
4764
4765
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.cont,f,keepdata))
4766 {
4767 return qe_invalid;
4768 }
4769
4770
1/2
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
52096 if(!p_getc(&tempDMap.type,f,keepdata))
4771 {
4772 return qe_invalid;
4773 }
4774
4775
4/4
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 51409 times.
✓ Branch 2 taken 675 times.
✓ Branch 3 taken 12 times.
52783 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4776
1/2
✓ Branch 0 taken 687 times.
✗ Branch 1 not taken.
687 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4777 675 tempDMap.xoff = 0;
4778
4779
2/2
✓ Branch 0 taken 416768 times.
✓ Branch 1 taken 52096 times.
468864 for(int32_t j=0; j<8; j++)
4780 {
4781
1/2
✓ Branch 0 taken 416768 times.
✗ Branch 1 not taken.
416768 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4782 {
4783 return qe_invalid;
4784 }
4785 416768 }
4786
4787
4/8
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51968 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52096 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4788 {
4789
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4790 {
4791 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4792 38 }
4793
4794
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4795 {
4796 4 tempDMap.cont-=tempDMap.xoff;
4797 4 tempDMap.compass-=tempDMap.xoff;
4798 4 }
4799
4800 //forgotten -DD
4801
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4802 {
4803 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4804 90 }
4805 128 }
4806 else
4807 {
4808
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4809 {
4810 return qe_invalid;
4811 }
4812
4813
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4814 {
4815 return qe_invalid;
4816 }
4817
4818
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4819 {
4820 return qe_invalid;
4821 }
4822
4823
3/8
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51968 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
51968 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4824 {
4825 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4826 if(keepdata==true)
4827 {
4828 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4829 }
4830
4831 continue;
4832 }
4833
4834
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4835 {
4836 if(!p_getc(&padding,f,keepdata))
4837 {
4838 return qe_invalid;
4839 }
4840 }
4841
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39680 times.
51968 if ( s_version >= 11 )
4842 {
4843
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4844 {
4845 return qe_invalid;
4846 }
4847 12288 }
4848 else
4849 {
4850
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4851 {
4852 return qe_invalid;
4853 }
4854 }
4855
4856
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4857 {
4858 return qe_invalid;
4859 }
4860
4861
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4862 {
4863 if(!p_getc(&padding,f,keepdata))
4864 {
4865 return qe_invalid;
4866 }
4867 }
4868
4869
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39680 times.
51968 if ( s_version >= 11 )
4870 {
4871
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4872 {
4873 return qe_invalid;
4874 }
4875 12288 }
4876 else
4877 {
4878
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4879 {
4880 return qe_invalid;
4881 }
4882 }
4883
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4884 {
4885 return qe_invalid;
4886 }
4887
4888
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4889 {
4890 if(!p_getc(&padding,f,keepdata))
4891 {
4892 return qe_invalid;
4893 }
4894 }
4895
4896
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39680 times.
51968 if ( s_version >= 11 )
4897 {
4898
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4899 {
4900 return qe_invalid;
4901 }
4902 12288 }
4903 else
4904 {
4905
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4906 {
4907 return qe_invalid;
4908 }
4909 }
4910
4911
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4912 {
4913 return qe_invalid;
4914 }
4915
4916
2/4
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51968 times.
✗ Branch 3 not taken.
51968 if(Header && (Header->zelda_version < 0x193))
4917 {
4918
4919 if(!p_getc(&padding,f,keepdata))
4920 {
4921 return qe_invalid;
4922 }
4923 }
4924
4925
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39680 times.
51968 if ( s_version >= 11 )
4926 {
4927
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4928 {
4929 return qe_invalid;
4930 }
4931 12288 }
4932 else
4933 {
4934
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4935 {
4936 return qe_invalid;
4937 }
4938 }
4939
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4940 {
4941 return qe_invalid;
4942 }
4943
4944
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4945 {
4946 return qe_invalid;
4947 }
4948 }
4949
4950
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version>1)
4951 {
4952
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4953 {
4954 return qe_invalid;
4955 }
4956
4957
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4958 {
4959 return qe_invalid;
4960 }
4961
4962
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4963 {
4964 return qe_invalid;
4965 }
4966 50688 }
4967
4968
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 50688 times.
52096 if(s_version>2)
4969 {
4970 byte di[32];
4971
4972
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!pfread(&di, 32, f, true)) return qe_invalid;
4973
4974
2/2
✓ Branch 0 taken 12976128 times.
✓ Branch 1 taken 50688 times.
13026816 for(int32_t j=0; j<MAXITEMS; j++)
4975 {
4976
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 12976121 times.
12976128 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4977 12976121 else tempDMap.disableditems[j]=0;
4978 12976128 }
4979 50688 }
4980
4981
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version >= 6)
4982 {
4983
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempDMap.flags,f,keepdata))
4984 {
4985 return qe_invalid;
4986 }
4987 50688 }
4988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
4989 {
4990 char temp;
4991
4992 if(!p_getc(&temp,f,keepdata))
4993 {
4994 return qe_invalid;
4995 }
4996
4997 tempDMap.flags = temp;
4998 }
4999
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5000 {
5001 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5002 697 }
5003 else
5004 711 tempDMap.flags=0;
5005
5006
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version<7)
5007 {
5008
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5009 697 tempDMap.flags|= dmfVIEWMAP;
5010 1408 }
5011
5012
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 1408 times.
52096 if(s_version<8)
5013 {
5014
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5015 {
5016 609 tempDMap.type &= ~dmDNGN;
5017 609 tempDMap.type |= dmCAVE;
5018 609 }
5019
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5020 {
5021 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5022 469 }
5023 1408 }
5024
5025
5/8
✓ Branch 0 taken 52096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 51968 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 51968 times.
✗ Branch 7 not taken.
52096 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5026 51968 && (Header->zelda_version < 0x193))
5027 {
5028 if(!p_getc(&padding,f,keepdata))
5029 {
5030 return qe_invalid;
5031 }
5032 }
5033
5034
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12288 times.
52096 if(s_version >= 10)
5035 {
5036
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&tempDMap.sideview,f,keepdata))
5037 {
5038 return qe_invalid;
5039 }
5040 12288 }
5041
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if(s_version < 10) tempDMap.sideview = 0;
5042
5043 //Dmap Scripts
5044
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12288 times.
52096 if(s_version >= 12)
5045 {
5046
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.script,f,keepdata))
5047 {
5048 return qe_invalid;
5049 }
5050
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
5051 {
5052
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5053 {
5054 return qe_invalid;
5055 }
5056 98304 }
5057 12288 }
5058
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if ( s_version < 12 )
5059 {
5060 39808 tempDMap.script = 0;
5061
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for ( int32_t q = 0; q < 8; q++ )
5062 {
5063 318464 tempDMap.initD[q] = 0;
5064 318464 }
5065 39808 }
5066
5067
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12288 times.
52096 if(s_version >= 13)
5068 {
5069
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
5070 {
5071
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; w++ )
5072 {
5073
1/2
✓ Branch 0 taken 6389760 times.
✗ Branch 1 not taken.
6389760 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5074 {
5075 return qe_invalid;
5076 }
5077 6389760 }
5078 98304 }
5079 12288 }
5080
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if ( s_version < 13 )
5081 {
5082 39808 tempDMap.script = 0;
5083
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for ( int32_t q = 0; q < 8; q++ )
5084 {
5085
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for ( int32_t w = 0; w < 65; w++ )
5086 20700160 tempDMap.initD_label[q][w] = 0;
5087 318464 }
5088 39808 }
5089
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if(s_version >= 14)
5090 {
5091
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5092 {
5093 return qe_invalid;
5094 }
5095
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5096 {
5097 return qe_invalid;
5098 }
5099
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; ++q )
5100 {
5101
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5102 {
5103 return qe_invalid;
5104 }
5105 98304 }
5106
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for(int32_t q = 0; q < 8; ++q)
5107 {
5108
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; ++w )
5109 {
5110
1/2
✓ Branch 0 taken 6389760 times.
✗ Branch 1 not taken.
6389760 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5111 {
5112 return qe_invalid;
5113 }
5114 6389760 }
5115 98304 }
5116 12288 }
5117 else
5118 {
5119 39808 tempDMap.active_sub_script = 0;
5120 39808 tempDMap.passive_sub_script = 0;
5121
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for(int32_t q = 0; q < 8; ++q)
5122 {
5123 318464 tempDMap.sub_initD[q] = 0;
5124
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for(int32_t w = 0; w < 65; ++w)
5125 20700160 tempDMap.sub_initD_label[q][w] = 0;
5126 318464 }
5127 }
5128
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if(s_version >= 15)
5129 {
5130
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5131 {
5132 return qe_invalid;
5133 }
5134
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; ++q )
5135 {
5136
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5137 {
5138 return qe_invalid;
5139 }
5140 98304 }
5141
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for(int32_t q = 0; q < 8; ++q)
5142 {
5143
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; ++w )
5144 {
5145
1/2
✓ Branch 0 taken 6389760 times.
✗ Branch 1 not taken.
6389760 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5146 {
5147 return qe_invalid;
5148 }
5149 6389760 }
5150 98304 }
5151 12288 }
5152 else
5153 {
5154 39808 tempDMap.onmap_script = 0;
5155
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for(int32_t q = 0; q < 8; ++q)
5156 {
5157 318464 tempDMap.onmap_initD[q] = 0;
5158
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for(int32_t w = 0; w < 65; ++w)
5159 {
5160 20700160 tempDMap.onmap_initD_label[q][w] = 0;
5161 20700160 }
5162 318464 }
5163 }
5164
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 39808 times.
52096 if(s_version >= 16)
5165 {
5166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5167 {
5168 return qe_invalid;
5169 }
5170 12288 }
5171 else
5172 {
5173 39808 tempDMap.mirrorDMap = -1;
5174 }
5175
5176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52096 times.
52096 if(keepdata==true)
5177 {
5178 52096 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5179 52096 }
5180 52096 }
5181
5182 108 return 0;
5183 108 }
5184
5185 99 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5186 {
5187 //these are here to bypass compiler warnings about unused arguments
5188 99 Header=Header;
5189
5190 miscQdata temp_misc;
5191 99 word s_version=0, s_cversion=0;
5192 99 int32_t tempsize=0;
5193 word dummyw;
5194
5195 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5196
5197 //section version info
5198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
5199 {
5200 return qe_invalid;
5201 }
5202
5203 99 FFCore.quest_format[vColours] = s_version;
5204
5205 99 al_trace("Misc Colours section version: %d\n", s_version);
5206
5207 //al_trace("Misc. colors version %d\n", s_version);
5208
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5209 {
5210 return qe_invalid;
5211 }
5212
5213
5214 //section size
5215
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5216 {
5217 return qe_invalid;
5218 }
5219
5220 //finally... section data
5221 99 readsize=0;
5222
5223
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.text,f,true))
5224 {
5225 return qe_invalid;
5226 }
5227
5228
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.caption,f,true))
5229 {
5230 return qe_invalid;
5231 }
5232
5233
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5234 {
5235 return qe_invalid;
5236 }
5237
5238
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5239 {
5240 return qe_invalid;
5241 }
5242
5243
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5244 {
5245 return qe_invalid;
5246 }
5247
5248
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5249 {
5250 return qe_invalid;
5251 }
5252
5253
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5259 {
5260 return qe_invalid;
5261 }
5262
5263
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5269 {
5270 return qe_invalid;
5271 }
5272
5273
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5274 {
5275 return qe_invalid;
5276 }
5277
5278
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5309 {
5310 return qe_invalid;
5311 }
5312
5313
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5319 {
5320 return qe_invalid;
5321 }
5322
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if(s_version < 4)
5323 {
5324
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5325 return qe_invalid;
5326 75 temp_misc.colors.triforce_tile = dummyw;
5327
5328
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5329 return qe_invalid;
5330 75 temp_misc.colors.triframe_tile = dummyw;
5331
5332
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5333 return qe_invalid;
5334 75 temp_misc.colors.overworld_map_tile = dummyw;
5335
5336
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5337 return qe_invalid;
5338 75 temp_misc.colors.dungeon_map_tile = dummyw;
5339
5340
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5341 return qe_invalid;
5342 75 temp_misc.colors.blueframe_tile = dummyw;
5343
5344
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5345 return qe_invalid;
5346 75 temp_misc.colors.HCpieces_tile = dummyw;
5347 75 }
5348
5349
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5355 {
5356 return qe_invalid;
5357 }
5358
5359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version < 2)
5360 {
5361 temp_misc.colors.msgtext = 0x01;
5362 }
5363 else
5364 {
5365
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5366 {
5367 return qe_invalid;
5368 }
5369 }
5370
5371
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if ( s_version >= 3 ) //expanded tile pages to 825
5372 {
5373
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5374 {
5375 return qe_invalid;
5376 }
5377
5378
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5379 {
5380 return qe_invalid;
5381 }
5382
5383
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5384 {
5385 return qe_invalid;
5386 }
5387
5388
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5389 {
5390 return qe_invalid;
5391 }
5392
5393
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5394 {
5395 return qe_invalid;
5396 }
5397
5398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5399 {
5400 return qe_invalid;
5401 }
5402 24 }
5403
5404
5405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
5406 {
5407 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5408 99 }
5409
5410 99 return 0;
5411 99 }
5412
5413 99 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5414 {
5415 miscQdata temp_misc;
5416 99 word s_version=0, s_cversion=0;
5417 byte icons;
5418 99 int32_t tempsize=0;
5419
5420 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5421
5422 //section version info
5423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
5424 {
5425 return qe_invalid;
5426 }
5427
5428 99 FFCore.quest_format[vIcons] = s_version;
5429
5430 //al_trace("Game icons version %d\n", s_version);
5431
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
5437 //section size
5438
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5439 {
5440 return qe_invalid;
5441 }
5442
5443 //finally... section data
5444 99 readsize=0;
5445
5446 99 icons=4;
5447
5448
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if ( s_version >= 10 )
5449 {
5450
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<icons; i++)
5451 {
5452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetl(&temp_misc.icons[i],f,true))
5453 {
5454 return qe_invalid;
5455 }
5456 96 }
5457 24 }
5458 else
5459 {
5460
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<icons; i++)
5461 {
5462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(!p_igetw(&temp_misc.icons[i],f,true))
5463 {
5464 return qe_invalid;
5465 }
5466 300 }
5467 }
5468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
5469 {
5470 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5471 99 }
5472
5473 99 return 0;
5474 99 }
5475
5476 108 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5477 {
5478 108 word maxinfos=256;
5479 108 word maxshops=256;
5480 108 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5481 108 word ponds=16, pondsize=72, expansionsize=98*2;
5482 byte tempbyte, padding;
5483 miscQdata temp_misc;
5484 108 word s_version=0, s_cversion=0;
5485 word swaptmp;
5486 108 int32_t tempsize=0;
5487
5488 108 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5489
5490
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxshops; ++i)
5491 {
5492 27648 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5493 27648 }
5494
5495
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxinfos; ++i)
5496 {
5497 27648 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5498 27648 }
5499
5500
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5501 {
5502 //section version info
5503
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
5504 {
5505 return qe_invalid;
5506 }
5507
5508 104 FFCore.quest_format[vMisc] = s_version;
5509
5510 //al_trace("Misc. data version %d\n", s_version);
5511
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
5512 {
5513 return qe_invalid;
5514 }
5515
5516
5517 //section size
5518
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&tempsize,f,true))
5519 {
5520 return qe_invalid;
5521 }
5522 104 }
5523
5524 //finally... section data
5525 108 readsize=0;
5526
5527 //shops
5528
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5529 {
5530
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&shops,f,true))
5531 {
5532 return qe_invalid;
5533 }
5534 104 }
5535
5536
2/2
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 108 times.
1251 for(int32_t i=0; i<shops; i++)
5537 {
5538
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1025 times.
1143 if(s_version > 6)
5539 {
5540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1025 times.
1025 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5541 {
5542 return qe_invalid;
5543 }
5544 1025 }
5545
5546
2/2
✓ Branch 0 taken 3429 times.
✓ Branch 1 taken 1143 times.
4572 for(int32_t j=0; j<3; j++)
5547 {
5548
1/2
✓ Branch 0 taken 3429 times.
✗ Branch 1 not taken.
3429 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5549 {
5550 return qe_invalid;
5551 }
5552
5553
2/2
✓ Branch 0 taken 3075 times.
✓ Branch 1 taken 354 times.
3429 if(s_version < 4)
5554 {
5555 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5556 354 }
5557 3429 }
5558
5559
2/2
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 64 times.
1143 if(Header->zelda_version < 0x193)
5560 {
5561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5562 {
5563 return qe_invalid;
5564 }
5565 64 }
5566
5567
2/2
✓ Branch 0 taken 3429 times.
✓ Branch 1 taken 1143 times.
4572 for(int32_t j=0; j<3; j++)
5568 {
5569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3429 times.
3429 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5570 {
5571 return qe_invalid;
5572 }
5573 3429 }
5574
5575
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1025 times.
1143 if(s_version > 3)
5576 {
5577
2/2
✓ Branch 0 taken 3075 times.
✓ Branch 1 taken 1025 times.
4100 for(int32_t j=0; j<3; j++)
5578 {
5579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3075 times.
3075 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5580 return qe_invalid;
5581 3075 }
5582 1025 }
5583
5584 /*
5585 if(s_version < 8)
5586 {
5587 for(int32_t j=0; j<3; j++)
5588 {
5589 (&temp_misc.shop[i].str[j])=0; //initialise.
5590 }
5591 }
5592 */
5593 1143 }
5594
5595 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5596
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxshops; ++i)
5597 {
5598
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 27648 times.
82944 for(int32_t j=0; j<3-1; j++)
5599 {
5600
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 55296 times.
138240 for(int32_t k=0; k<2-j; k++)
5601 {
5602
2/2
✓ Branch 0 taken 2403 times.
✓ Branch 1 taken 80541 times.
82944 if(temp_misc.shop[i].hasitem[k]==0)
5603 {
5604 80541 swaptmp = temp_misc.shop[i].item[k];
5605 80541 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5606 80541 temp_misc.shop[i].item[k+1] = swaptmp;
5607 80541 swaptmp = temp_misc.shop[i].price[k];
5608 80541 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5609 80541 temp_misc.shop[i].price[k+1] = swaptmp;
5610 80541 swaptmp = temp_misc.shop[i].hasitem[k];
5611 80541 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5612 80541 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5613 80541 }
5614 82944 }
5615 55296 }
5616 27648 }
5617
5618 //infos
5619
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5620 {
5621
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&infos,f,true))
5622 {
5623 return qe_invalid;
5624 }
5625 104 }
5626
5627
2/2
✓ Branch 0 taken 1538 times.
✓ Branch 1 taken 108 times.
1646 for(int32_t i=0; i<infos; i++)
5628 {
5629
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1459 times.
1538 if(s_version > 6)
5630 {
5631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1459 times.
1459 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5632 {
5633 return qe_invalid;
5634 }
5635 1459 }
5636
5637
2/2
✓ Branch 0 taken 4614 times.
✓ Branch 1 taken 1538 times.
6152 for(int32_t j=0; j<3; j++)
5638 {
5639
2/4
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4614 if((Header->zelda_version < 0x192)||
5640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4422 times.
4422 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5641 {
5642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5643 {
5644 return qe_invalid;
5645 }
5646
5647 192 temp_misc.info[i].str[j]=tempbyte;
5648 192 }
5649 else
5650 {
5651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4422 times.
4422 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5652 {
5653 return qe_invalid;
5654 }
5655 }
5656 4614 }
5657
5658
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 64 times.
1538 if(Header->zelda_version < 0x193)
5659 {
5660
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5661 {
5662 return qe_invalid;
5663 }
5664 64 }
5665
5666
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1538 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1538 if((Header->zelda_version == 0x192)&&(Header->build>145))
5667 {
5668 if(!p_getc(&padding,f,true))
5669 {
5670 return qe_invalid;
5671 }
5672 }
5673
5674
2/2
✓ Branch 0 taken 4614 times.
✓ Branch 1 taken 1538 times.
6152 for(int32_t j=0; j<3; j++)
5675 {
5676
1/2
✓ Branch 0 taken 4614 times.
✗ Branch 1 not taken.
4614 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5677 {
5678 return qe_invalid;
5679 }
5680 4614 }
5681 1538 }
5682
5683 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5684
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<maxinfos; ++i)
5685 {
5686
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 27648 times.
82944 for(int32_t j=0; j<3-1; j++)
5687 {
5688
2/2
✓ Branch 0 taken 82944 times.
✓ Branch 1 taken 55296 times.
138240 for(int32_t k=0; k<2-j; k++)
5689 {
5690
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 81147 times.
82944 if(temp_misc.info[i].str[k]==0)
5691 {
5692 81147 swaptmp = temp_misc.info[i].str[k];
5693 81147 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5694 81147 temp_misc.info[i].str[k+1] = swaptmp;
5695 81147 swaptmp = temp_misc.info[i].price[k];
5696 81147 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5697 81147 temp_misc.info[i].price[k+1] = swaptmp;
5698 81147 }
5699 82944 }
5700 55296 }
5701 27648 }
5702
5703
5704 //warp rings
5705
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version > 5)
5706 99 warprings++;
5707
5708
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
5709 {
5710
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&warprings,f,true))
5711 {
5712 return qe_invalid;
5713 }
5714 104 }
5715
5716
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 108 times.
1164 for(int32_t i=0; i<warprings; i++)
5717 {
5718
2/2
✓ Branch 0 taken 9392 times.
✓ Branch 1 taken 1056 times.
10448 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5719 {
5720
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 8496 times.
9392 if(s_version <= 3)
5721 {
5722
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,true))
5723 {
5724 return qe_invalid;
5725 }
5726
5727 896 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5728 896 }
5729 else
5730 {
5731
1/2
✓ Branch 0 taken 8496 times.
✗ Branch 1 not taken.
8496 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5732 {
5733 return qe_invalid;
5734 }
5735 }
5736 9392 }
5737
5738
2/2
✓ Branch 0 taken 9392 times.
✓ Branch 1 taken 1056 times.
10448 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5739 {
5740
1/2
✓ Branch 0 taken 9392 times.
✗ Branch 1 not taken.
9392 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5741 {
5742 return qe_invalid;
5743 }
5744 9392 }
5745
5746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
1056 if(!p_getc(&temp_misc.warp[i].size,f,true))
5747 {
5748 return qe_invalid;
5749 }
5750
5751
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 32 times.
1056 if(Header->zelda_version < 0x193)
5752 {
5753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5754 {
5755 return qe_invalid;
5756 }
5757 32 }
5758 1056 }
5759
5760 //palette cycles
5761
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5762 {
5763
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5764 {
5765
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5766 {
5767 3072 temp_misc.cycles[i][j].first=0;
5768 3072 temp_misc.cycles[i][j].count=0;
5769 3072 temp_misc.cycles[i][j].speed=0;
5770 3072 }
5771 1024 }
5772
5773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5774 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5775 {
5776 4 palcycles=16;
5777 4 }
5778
5779
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5780 {
5781
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5782 {
5783
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5784 {
5785 return qe_invalid;
5786 }
5787
5788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5789 {
5790 return qe_invalid;
5791 }
5792
5793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5794 {
5795 return qe_invalid;
5796 }
5797 192 }
5798 64 }
5799 4 }
5800
5801 //Wind warps are now just another warp ring.
5802
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version <= 5)
5803 {
5804
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5805 {
5806
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5807 {
5808 return qe_invalid;
5809 }
5810 5 }
5811
5812
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5813 {
5814
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5815 {
5816
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5817 {
5818 return qe_invalid;
5819 }
5820
5821 79 temp_misc.warp[8].dmap[i]=tempbyte;
5822 79 }
5823 else
5824 {
5825 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5826 {
5827 return qe_invalid;
5828 }
5829 }
5830
5831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5832 {
5833 return qe_invalid;
5834 }
5835
5836 79 temp_misc.warp[8].size = 9;
5837
5838
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5839 {
5840 if(!p_getc(&tempbyte,f,true))
5841 {
5842 return qe_invalid;
5843 }
5844 }
5845 79 }
5846 9 }
5847
5848
5849 //triforce pieces
5850
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<triforces; i++)
5851 {
5852
1/2
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
864 if(!p_getc(&temp_misc.triforce[i],f,true))
5853 {
5854 return qe_invalid;
5855 }
5856 864 }
5857
5858 //misc color data
5859
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<3)
5860 {
5861
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5862 {
5863 return qe_invalid;
5864 }
5865
5866
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5867 {
5868 return qe_invalid;
5869 }
5870
5871
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5872 {
5873 return qe_invalid;
5874 }
5875
5876
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5877 {
5878 return qe_invalid;
5879 }
5880
5881
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5882 {
5883 return qe_invalid;
5884 }
5885
5886
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5887 {
5888 return qe_invalid;
5889 }
5890
5891
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5892 {
5893 return qe_invalid;
5894 }
5895
5896
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5897 {
5898 return qe_invalid;
5899 }
5900
5901
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5902 {
5903 return qe_invalid;
5904 }
5905
5906
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5907 {
5908 return qe_invalid;
5909 }
5910
5911
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5912 {
5913 return qe_invalid;
5914 }
5915
5916
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5917 {
5918 return qe_invalid;
5919 }
5920
5921
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5922 {
5923 return qe_invalid;
5924 }
5925
5926
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5927 {
5928 return qe_invalid;
5929 }
5930
5931
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5932 {
5933 return qe_invalid;
5934 }
5935
5936
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5937 {
5938 return qe_invalid;
5939 }
5940
5941
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5942 {
5943 return qe_invalid;
5944 }
5945
5946
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5947 {
5948 return qe_invalid;
5949 }
5950
5951
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5952 {
5953 return qe_invalid;
5954 }
5955
5956
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5957 {
5958 return qe_invalid;
5959 }
5960
5961
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5962 {
5963 return qe_invalid;
5964 }
5965
5966
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5967 {
5968 return qe_invalid;
5969 }
5970
5971
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5972 {
5973 return qe_invalid;
5974 }
5975
5976
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5977 {
5978 return qe_invalid;
5979 }
5980
5981
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5982 {
5983 return qe_invalid;
5984 }
5985
5986
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5987 {
5988 return qe_invalid;
5989 }
5990
5991
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5992 {
5993 return qe_invalid;
5994 }
5995
5996 9 temp_misc.colors.msgtext = 0x01;
5997
5998
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
5999 {
6000
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6001 {
6002
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6003 {
6004 return qe_invalid;
6005 }
6006 28 }
6007 4 }
6008
6009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6010 {
6011 for(int32_t i=0; i<256; i++)
6012 {
6013 if(!p_getc(&tempbyte,f,true))
6014 {
6015 return qe_invalid;
6016 }
6017 }
6018 }
6019
6020
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6021 {
6022 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6023 {
6024 return qe_invalid;
6025 }
6026 }
6027
6028 //save game icons
6029
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6031 {
6032 4 icons=3;
6033 4 }
6034
6035
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6036 {
6037
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6038 {
6039 return qe_invalid;
6040 }
6041 32 }
6042 9 }
6043
6044
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
6045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6046 {
6047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6048 {
6049 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6050 4 }
6051
6052 4 return 0;
6053 }
6054
6055 //pond information
6056
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
6057 {
6058 if((Header->zelda_version == 0x192)&&(Header->build<146))
6059 {
6060 pondsize=25;
6061 }
6062
6063 for(int32_t i=0; i<ponds; i++)
6064 {
6065 for(int32_t j=0; j<pondsize; j++)
6066 {
6067 if(!p_getc(&tempbyte,f,true))
6068 {
6069 return qe_invalid;
6070
6071 }
6072 }
6073 }
6074 }
6075
6076 //end string
6077
1/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version < 0x192)||
6078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6079 {
6080 if(!p_getc(&tempbyte,f,true))
6081 {
6082 return qe_invalid;
6083 }
6084
6085 temp_misc.endstring=tempbyte;
6086
6087 if(!p_getc(&tempbyte,f,true))
6088 {
6089 return qe_invalid;
6090 }
6091 }
6092 else
6093 {
6094
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&temp_misc.endstring,f,true))
6095 {
6096 return qe_invalid;
6097 }
6098 }
6099
6100 //expansion
6101
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
6102 {
6103 if((Header->zelda_version == 0x192)&&(Header->build<73))
6104 {
6105 expansionsize=99*2;
6106 }
6107
6108 for(int32_t i=0; i<expansionsize; i++)
6109 {
6110 if(!p_getc(&tempbyte,f,true))
6111 {
6112 return qe_invalid;
6113 }
6114 }
6115 }
6116 //shops v8
6117
6118
6119
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if(s_version >= 8)
6120 {
6121
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 24 times.
376 for(int32_t i=0; i<shops; i++)
6122 {
6123
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 352 times.
1408 for(int32_t j=0; j<3; j++)
6124 {
6125
1/2
✓ Branch 0 taken 1056 times.
✗ Branch 1 not taken.
1056 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6126 return qe_invalid;
6127 1056 }
6128 352 }
6129 24 }
6130
6131 104 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6132 104 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6133 104 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6134
6135 //v9 includes quest misc[32]
6136
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if(s_version >= 9)
6137 {
6138
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24 times.
792 for ( int32_t q = 0; q < 32; q++ )
6139 {
6140
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6141 return qe_invalid;
6142 768 }
6143
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24 times.
792 for ( int32_t q = 0; q < 32; q++ )
6144 {
6145
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 768 times.
99072 for ( int32_t j = 0; j < 128; j++ )
6146
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6147 return qe_invalid;
6148 768 }
6149 24 }
6150
6151
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(s_version >= 11 )
6152 {
6153
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6154 return qe_invalid;
6155 24 }
6156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 else if(s_version < 11 )
6157 {
6158 80 temp_misc.zscript_last_compiled_version = -1;
6159 80 }
6160
6161 104 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6162
6163
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(s_version >= 12)
6164 {
6165 byte spr;
6166
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t q = 0; q < sprMAX; ++q)
6167 {
6168
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&spr,f,true))
6169 return qe_invalid;
6170 6144 temp_misc.sprites[q] = spr;
6171 6144 }
6172 24 }
6173 else
6174 {
6175 80 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6176 //temp_misc.sprites[sprFALL] = ;
6177 }
6178
6179
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(s_version >= 13)
6180 {
6181
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 24 times.
1560 for(size_t q = 0; q < 64; ++q)
6182 {
6183 1536 bottletype* bt = &(temp_misc.bottle_types[q]);
6184
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!pfread(bt->name, 32, f, true))
6185 return qe_invalid;
6186
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 1536 times.
6144 for(size_t j = 0; j < 3; ++j)
6187 {
6188
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 if (!p_getc(&(bt->counter[j]), f, true))
6189 return qe_invalid;
6190
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
4608 if (!p_igetw(&(bt->amount[j]), f, true))
6191 return qe_invalid;
6192 4608 }
6193
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_getc(&(bt->flags), f, true))
6194 return qe_invalid;
6195
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_getc(&(bt->next_type), f, true))
6196 return qe_invalid;
6197 1536 }
6198
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(size_t q = 0; q < 256; ++q)
6199 {
6200 6144 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6201
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if (!pfread(bst->name, 32, f, true))
6202 return qe_invalid;
6203
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(size_t j = 0; j < 3; ++j)
6204 {
6205
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (!p_getc(&(bst->fill[j]), f, true))
6206 return qe_invalid;
6207
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (!p_igetw(&(bst->comb[j]), f, true))
6208 return qe_invalid;
6209
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (!p_getc(&(bst->cset[j]), f, true))
6210 return qe_invalid;
6211
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (!p_igetw(&(bst->price[j]), f, true))
6212 return qe_invalid;
6213
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (!p_igetw(&(bst->str[j]), f, true))
6214 return qe_invalid;
6215 18432 }
6216 6144 }
6217 24 }
6218 else
6219 {
6220
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 80 times.
5200 for(size_t q = 0; q < 64; ++q)
6221 5120 temp_misc.bottle_types[q].clear();
6222
2/2
✓ Branch 0 taken 20480 times.
✓ Branch 1 taken 80 times.
20560 for(size_t q = 0; q < 256; ++q)
6223 20480 temp_misc.bottle_shop_types[q].clear();
6224 }
6225
6226
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(s_version >= 14)
6227 {
6228 byte msfx;
6229
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t q = 0; q < sfxMAX; ++q)
6230 {
6231
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&msfx,f,true))
6232 return qe_invalid;
6233 6144 temp_misc.miscsfx[q] = msfx;
6234 6144 }
6235 24 }
6236 else
6237 {
6238 80 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6239 80 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6240 80 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6241 }
6242
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if(s_version < 15)
6243 {
6244 80 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6245 80 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6246 80 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6247 80 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6248 80 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6249 80 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6250 80 }
6251
6252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
6253 {
6254 104 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6255 104 }
6256
6257 104 return 0;
6258 108 }
6259
6260 extern char *item_string[ITEMCNT];
6261 extern const char *old_item_string[iLast];
6262 extern char *weapon_string[WPNCNT];
6263 extern const char *old_weapon_string[wLast];
6264
6265 108 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6266 {
6267 byte padding;
6268 int32_t dummy;
6269 108 word items_to_read=MAXITEMS;
6270 itemdata tempitem;
6271 108 word s_version=0, s_cversion=0;
6272 word dummy_word;
6273
6274
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(version < 0x186)
6275 {
6276 items_to_read=64;
6277 }
6278
6279
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
6280 {
6281 104 items_to_read=0;
6282
6283 //section version info
6284
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
6285 {
6286 return qe_invalid;
6287 }
6288
6289 104 FFCore.quest_format[vItems] = s_version;
6290
6291 //al_trace("Items version %d\n", s_version);
6292
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
6293 {
6294 return qe_invalid;
6295 }
6296
6297 //section size
6298
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
6299 {
6300 return qe_invalid;
6301 }
6302
6303 //finally... section data
6304
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&items_to_read,f,true))
6305 {
6306 return qe_invalid;
6307 }
6308 104 }
6309
6310
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version>1)
6311 {
6312
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<items_to_read; i++)
6313 {
6314 char tempname[64];
6315
6316
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!pfread(tempname, 64, f, keepdata))
6317 {
6318 return qe_invalid;
6319 }
6320
6321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(keepdata)
6322 {
6323 25344 strcpy(item_string[i], tempname);
6324 25344 }
6325 25344 }
6326 99 }
6327 else
6328 {
6329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6330 {
6331
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6332 {
6333 2304 reset_itemname(i);
6334 2304 }
6335 9 }
6336 }
6337
6338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
6339 {
6340
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMS; i++)
6341 {
6342 27648 itemdata& id = itemsbuf[i];
6343 27648 memset(&id, 0, sizeof(itemdata));
6344 27648 id.count=-1;
6345 27648 id.playsound=WAV_SCALE;
6346 27648 reset_itembuf(&id,i);
6347 27648 }
6348 108 }
6349
6350
2/2
✓ Branch 0 taken 26718 times.
✓ Branch 1 taken 108 times.
26826 for(int32_t i=0; i<items_to_read; i++)
6351 {
6352 26718 memset(&tempitem, 0, sizeof(itemdata));
6353 26718 reset_itembuf(&tempitem,i);
6354
6355
6356
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 20574 times.
26718 if ( s_version > 35 ) //expanded tiles
6357 {
6358
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.tile,f,true))
6359 {
6360 return qe_invalid;
6361 }
6362 6144 }
6363 else
6364 {
6365
1/2
✓ Branch 0 taken 20574 times.
✗ Branch 1 not taken.
20574 if(!p_igetw(&tempitem.tile,f,true))
6366 {
6367 return qe_invalid;
6368 }
6369 }
6370
6371
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.misc_flags,f,true))
6372 {
6373 return qe_invalid;
6374 }
6375
6376
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.csets,f,true))
6377 {
6378 return qe_invalid;
6379 }
6380
6381
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.frames,f,true))
6382 {
6383 return qe_invalid;
6384 }
6385
6386
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.speed,f,true))
6387 {
6388 return qe_invalid;
6389 }
6390
6391
1/2
✓ Branch 0 taken 26718 times.
✗ Branch 1 not taken.
26718 if(!p_getc(&tempitem.delay,f,true))
6392 {
6393 return qe_invalid;
6394 }
6395
6396
2/2
✓ Branch 0 taken 25694 times.
✓ Branch 1 taken 1024 times.
26718 if(version < 0x193)
6397 {
6398
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6399 {
6400 return qe_invalid;
6401 }
6402
6403
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6404 {
6405
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6406 {
6407 case iShield:
6408 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6409 4 break;
6410
6411 case iMShield:
6412 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6413 4 break;
6414
6415 default:
6416 1016 tempitem.ltm=0;
6417 1016 break;
6418 }
6419
6420 1024 tempitem.count=-1;
6421 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6422 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6423 1024 tempitem.family=0xFF;
6424 1024 tempitem.playsound=WAV_SCALE;
6425 1024 reset_itembuf(&tempitem,i);
6426
6427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6428 {
6429 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6430 1024 }
6431
6432 1024 continue;
6433 }
6434 }
6435
6436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25694 times.
25694 if(!p_igetl(&tempitem.ltm,f,true))
6437 {
6438 return qe_invalid;
6439 }
6440
6441
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(version < 0x193)
6442 {
6443 for(int32_t q=0; q<12; q++)
6444 {
6445 if(!p_getc(&padding,f,true))
6446 {
6447 return qe_invalid;
6448 }
6449 }
6450 }
6451
6452
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 350 times.
25694 if(s_version>1)
6453 {
6454
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 19200 times.
25344 if ( s_version >= 31 )
6455 {
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.family,f,true))
6457 {
6458 return qe_invalid;
6459 }
6460 6144 }
6461 else
6462 {
6463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(!p_getc(&tempitem.family,f,true))
6464 {
6465 return qe_invalid;
6466 }
6467 }
6468
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version < 16)
6469 if(tempitem.family == 0xFF)
6470 tempitem.family = itype_misc;
6471
6472
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.fam_type,f,true))
6473 {
6474 return qe_invalid;
6475 }
6476
6477
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version>5)
6478 {
6479
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 19200 times.
25344 if(s_version>=31)
6480 {
6481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.power,f,true))
6482 {
6483 return qe_invalid;
6484 }
6485 6144 }
6486 else
6487 {
6488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(!p_getc(&tempitem.power,f,true))
6489 {
6490 return qe_invalid;
6491 }
6492 }
6493
6494 //converted flags from 16b to 32b -Z
6495
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version < 41 )
6496 {
6497
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_igetw(&tempitem.flags,f,true))
6498 {
6499 return qe_invalid;
6500 }
6501 19200 }
6502 else
6503 {
6504
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.flags,f,true))
6505 {
6506 return qe_invalid;
6507 }
6508 }
6509 25344 }
6510 else
6511 {
6512 //tempitem.power = tempitem.fam_type;
6513 char tempchar;
6514
6515 if(!p_getc(&tempchar,f,true))
6516 {
6517 return qe_invalid;
6518 }
6519
6520 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6521 }
6522
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.script,f,true))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<=3)
6529 {
6530 if(tempitem.script > NUMSCRIPTITEM)
6531 {
6532 tempitem.script = 0;
6533 }
6534 }
6535
6536
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.count,f,true))
6537 {
6538 return qe_invalid;
6539 }
6540
6541
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetw(&tempitem.amount,f,true))
6542 {
6543 return qe_invalid;
6544 }
6545
6546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.collect_script,f,true))
6547 {
6548 return qe_invalid;
6549 }
6550
6551
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<=3)
6552 {
6553 if(tempitem.collect_script > NUMSCRIPTITEM)
6554 {
6555 tempitem.collect_script = 0;
6556 }
6557 }
6558
6559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.setmax,f,true))
6560 {
6561 return qe_invalid;
6562 }
6563
6564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetw(&tempitem.max,f,true))
6565 {
6566 return qe_invalid;
6567 }
6568
6569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.playsound,f,true))
6570 {
6571 return qe_invalid;
6572 }
6573
6574
2/2
✓ Branch 0 taken 202752 times.
✓ Branch 1 taken 25344 times.
228096 for(int32_t j=0; j<8; j++)
6575 {
6576
1/2
✓ Branch 0 taken 202752 times.
✗ Branch 1 not taken.
202752 if(!p_igetl(&tempitem.initiald[j],f,true))
6577 {
6578 return qe_invalid;
6579 }
6580 202752 }
6581
6582
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<2; j++)
6583 {
6584
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempitem.initiala[j],f,true))
6585 {
6586 return qe_invalid;
6587 }
6588 50688 }
6589
6590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>4)
6591 {
6592
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version>5)
6593 {
6594
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn,f,true))
6595 {
6596 return qe_invalid;
6597 }
6598
6599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn2,f,true))
6600 {
6601 return qe_invalid;
6602 }
6603
6604
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn3,f,true))
6605 {
6606 return qe_invalid;
6607 }
6608
6609
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn4,f,true))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>=15)
6615 {
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn5,f,true))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn6,f,true))
6622 {
6623 return qe_invalid;
6624 }
6625
6626
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn7,f,true))
6627 {
6628 return qe_invalid;
6629 }
6630
6631
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn8,f,true))
6632 {
6633 return qe_invalid;
6634 }
6635
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_getc(&tempitem.wpn9,f,true))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.wpn10,f,true))
6642 {
6643 return qe_invalid;
6644 }
6645 25344 }
6646
6647
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.pickup_hearts,f,true))
6648 {
6649 return qe_invalid;
6650 }
6651
6652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version<15)
6653 {
6654 if(!p_igetw(&dummy_word,f,true))
6655 {
6656 return qe_invalid;
6657 }
6658
6659 tempitem.misc1=dummy_word;
6660
6661 if(!p_igetw(&dummy_word,f,true))
6662 {
6663 return qe_invalid;
6664 }
6665
6666 tempitem.misc2=dummy_word;
6667 }
6668 else
6669 {
6670
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc1,f,true))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc2,f,true))
6676 {
6677 return qe_invalid;
6678 }
6679
6680 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6681
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(s_version<24)
6682 {
6683 if(tempitem.family==itype_shield)
6684 {
6685 tempitem.misc1|=shSCRIPT;
6686 }
6687 }
6688 }
6689
6690
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if(s_version < 53)
6691 {
6692 byte tempbyte;
6693
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_getc(&tempbyte,f,true))
6694 {
6695 return qe_invalid;
6696 }
6697 19200 tempitem.cost_amount[0] = tempbyte;
6698 19200 }
6699 else
6700 {
6701
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for(auto q = 0; q < 2; ++q)
6702 {
6703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6704 {
6705 return qe_invalid;
6706 }
6707 12288 }
6708 }
6709 25344 }
6710 else
6711 {
6712 char tempchar;
6713
6714 if(!p_getc(&tempchar,f,true))
6715 {
6716 return qe_invalid;
6717 }
6718
6719 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6720 }
6721
6722 // June 2007: more misc. attributes
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version>=12)
6724 {
6725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(s_version<15)
6726 {
6727 if(!p_igetw(&dummy_word,f,true))
6728 {
6729 return qe_invalid;
6730 }
6731
6732 tempitem.misc3=dummy_word;
6733
6734 if(!p_igetw(&dummy_word,f,true))
6735 {
6736 return qe_invalid;
6737 }
6738
6739 tempitem.misc4=dummy_word;
6740 }
6741 else
6742 {
6743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc3,f,true))
6744 {
6745 return qe_invalid;
6746 }
6747
6748
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc4,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752
6753
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc5,f,true))
6754 {
6755 return qe_invalid;
6756 }
6757
6758
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc6,f,true))
6759 {
6760 return qe_invalid;
6761 }
6762
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc7,f,true))
6764 {
6765 return qe_invalid;
6766 }
6767
6768
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc8,f,true))
6769 {
6770 return qe_invalid;
6771 }
6772
6773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(!p_igetl(&tempitem.misc9,f,true))
6774 {
6775 return qe_invalid;
6776 }
6777
6778
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_igetl(&tempitem.misc10,f,true))
6779 {
6780 return qe_invalid;
6781 }
6782 }
6783
6784
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!p_getc(&tempitem.usesound,f,true))
6785 {
6786 return qe_invalid;
6787 }
6788
6789
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 19200 times.
25344 if(s_version >= 49)
6790 {
6791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_getc(&tempitem.usesound2,f,true))
6792 {
6793 return qe_invalid;
6794 }
6795 6144 }
6796 19200 else tempitem.usesound2 = 0;
6797
6798
3/4
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
✓ Branch 2 taken 19200 times.
✗ Branch 3 not taken.
25344 if(s_version < 50 && tempitem.family == itype_mirror)
6799 {
6800 //Split continue/dmap warp effect/sfx, port for old
6801 tempitem.misc2 = tempitem.misc1;
6802 tempitem.usesound2 = tempitem.usesound;
6803 }
6804 25344 }
6805 25344 }
6806
6807
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6808 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_getc(&tempitem.useweapon,f,true))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_getc(&tempitem.usedefence,f,true))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weaprange,f,true))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weapduration,f,true))
6822 {
6823 return qe_invalid;
6824 }
6825
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 6144 times.
67584 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6826 {
6827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61440 times.
61440 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6828 {
6829 return qe_invalid;
6830 }
6831 61440 }
6832 6144 }
6833
6834
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6835 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6836
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.duplicates,f,true))
6837 {
6838 return qe_invalid;
6839 }
6840
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 6144 times.
55296 for ( int32_t q = 0; q < INITIAL_D; q++ )
6841 {
6842
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6843 {
6844 return qe_invalid;
6845 }
6846 49152 }
6847
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for ( int32_t q = 0; q < INITIAL_A; q++ )
6848 {
6849
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6850 {
6851 return qe_invalid;
6852 }
6853 12288 }
6854
6855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_getc(&tempitem.drawlayer,f,true))
6856 {
6857 return qe_invalid;
6858 }
6859
6860
6861
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.hxofs,f,true))
6862 {
6863 return qe_invalid;
6864 }
6865
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.hyofs,f,true))
6866 {
6867 return qe_invalid;
6868 }
6869
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.hxsz,f,true))
6870 {
6871 return qe_invalid;
6872 }
6873
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.hysz,f,true))
6874 {
6875 return qe_invalid;
6876 }
6877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.hzsz,f,true))
6878 {
6879 return qe_invalid;
6880 }
6881
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.xofs,f,true))
6882 {
6883 return qe_invalid;
6884 }
6885
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.yofs,f,true))
6886 {
6887 return qe_invalid;
6888 }
6889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6890 {
6891 return qe_invalid;
6892 }
6893
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6894 {
6895 return qe_invalid;
6896 }
6897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6898 {
6899 return qe_invalid;
6900 }
6901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weap_hysz,f,true))
6902 {
6903 return qe_invalid;
6904 }
6905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6906 {
6907 return qe_invalid;
6908 }
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weap_xofs,f,true))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_yofs,f,true))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetw(&tempitem.weaponscript,f,true))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.wpnsprite,f,true))
6922 {
6923 return qe_invalid;
6924 }
6925 6144 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6926
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for(auto q = 0; q < num_cost_tmr; ++q)
6927 {
6928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6929 {
6930 return qe_invalid;
6931 }
6932 12288 }
6933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 for(auto q = num_cost_tmr; q < 2; ++q)
6934 tempitem.magiccosttimer[q] = 0;
6935 6144 }
6936
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6937 {
6938 //Item Size FLags, TileWidth, TileHeight
6939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.tilew,f,true))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.tileh,f,true))
6948 {
6949 return qe_invalid;
6950 }
6951 6144 }
6952
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 29 ) //! More new vars.
6953 {
6954 //Item Size FLags, TileWidth, TileHeight
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6956 {
6957 return qe_invalid;
6958 }
6959
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_tilew,f,true))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.weap_tileh,f,true))
6964 {
6965 return qe_invalid;
6966 }
6967 6144 }
6968
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 30 ) //! More new vars.
6969 {
6970 //Pickup Type
6971
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempitem.pickup,f,true))
6972 {
6973 return qe_invalid;
6974 }
6975 6144 }
6976
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 32 ) //! More new vars.
6977 {
6978 //Pickup Type
6979
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetw(&tempitem.pstring,f,true))
6980 {
6981 return qe_invalid;
6982 }
6983 6144 }
6984
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 33 ) //! More new vars.
6985 {
6986 //Pickup Type
6987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6988 {
6989 return qe_invalid;
6990 }
6991 6144 }
6992
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 34 ) //! cost counter
6993 {
6994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 if(s_version < 53)
6995 {
6996 if(!p_getc(&tempitem.cost_counter[0],f,true))
6997 {
6998 return qe_invalid;
6999 }
7000 }
7001 else
7002 {
7003
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for(auto q = 0; q < 2; ++q)
7004 {
7005
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&tempitem.cost_counter[q],f,true))
7006 {
7007 return qe_invalid;
7008 }
7009 12288 }
7010 }
7011 6144 }
7012
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 44 ) //! sprite scripts
7013 {
7014
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 6144 times.
55296 for ( int32_t q = 0; q < 8; q++ )
7015 {
7016
2/2
✓ Branch 0 taken 3194880 times.
✓ Branch 1 taken 49152 times.
3244032 for ( int32_t w = 0; w < 65; w++ )
7017 {
7018
1/2
✓ Branch 0 taken 3194880 times.
✗ Branch 1 not taken.
3194880 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7019 {
7020 return qe_invalid;
7021 }
7022 3194880 }
7023
2/2
✓ Branch 0 taken 3194880 times.
✓ Branch 1 taken 49152 times.
3244032 for ( int32_t w = 0; w < 65; w++ )
7024 {
7025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3194880 times.
3194880 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7026 {
7027 return qe_invalid;
7028 }
7029 3194880 }
7030
2/2
✓ Branch 0 taken 3194880 times.
✓ Branch 1 taken 49152 times.
3244032 for ( int32_t w = 0; w < 65; w++ )
7031 {
7032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3194880 times.
3194880 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7033 {
7034 return qe_invalid;
7035 }
7036 3194880 }
7037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7038 {
7039 return qe_invalid;
7040 }
7041
7042 49152 }
7043
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 6144 times.
18432 for ( int32_t q = 0; q < 2; q++ )
7044 {
7045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7046 {
7047 return qe_invalid;
7048 }
7049 12288 }
7050 //Pickup Type
7051
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetw(&tempitem.sprite_script,f,true))
7052 {
7053 return qe_invalid;
7054 }
7055 6144 }
7056
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6144 times.
25344 if ( s_version >= 48 ) //! pickup flags
7057 {
7058
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7059 {
7060 return qe_invalid;
7061 }
7062 6144 }
7063
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 2048 times.
25344 if ( s_version >= 57 )
7064 {
7065 2048 std::string str;
7066
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✓ Branch 2 taken 2048 times.
✗ Branch 3 not taken.
2048 if(!p_getcstr(&str,f,true))
7067 return qe_invalid;
7068 2048 strncpy(tempitem.display_name,str.c_str(),255);
7069
1/3
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2048 }
7070 25344 }
7071 else
7072 {
7073 350 tempitem.count=-1;
7074 350 tempitem.family=itype_misc;
7075 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7076 350 tempitem.playsound=WAV_SCALE;
7077 350 reset_itembuf(&tempitem,i);
7078 }
7079
7080
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(keepdata==true)
7081 {
7082 25694 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7083 25694 }
7084 else if(zgpmode)
7085 {
7086 itemsbuf[i].tile=tempitem.tile;
7087 itemsbuf[i].misc_flags=tempitem.misc_flags;
7088 itemsbuf[i].csets=tempitem.csets;
7089 itemsbuf[i].frames=tempitem.frames;
7090 itemsbuf[i].speed=tempitem.speed;
7091 itemsbuf[i].delay=tempitem.delay;
7092 itemsbuf[i].ltm=tempitem.ltm;
7093 }
7094 25694 }
7095
7096 //////////////////////////////////////////////////////
7097 // Now do any updates because of new item additions
7098 // (These can't be done above because items_to_read
7099 // might be too low.)
7100 //////////////////////////////////////////////////////
7101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
7102 {
7103
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMS; i++)
7104 {
7105 27648 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7106
7107 //Account for older quests that didn't have an actual item for the used letter
7108
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 2 && i==iLetterUsed)
7109 {
7110 9 reset_itembuf(&tempitem, iLetterUsed);
7111 9 strcpy(item_string[i],old_item_string[i]);
7112 9 tempitem.tile = itemsbuf[iLetter].tile;
7113 9 tempitem.csets = itemsbuf[iLetter].csets;
7114 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7115 9 tempitem.frames = itemsbuf[iLetter].frames;
7116 9 tempitem.speed = itemsbuf[iLetter].speed;
7117 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7118 9 }
7119
7120
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 3)
7121 {
7122
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7123 {
7124 case iRocsFeather:
7125 case iHoverBoots:
7126 case iSpinScroll:
7127 case iL2SpinScroll:
7128 case iCrossScroll:
7129 case iQuakeScroll:
7130 case iL2QuakeScroll:
7131 case iWhispRing:
7132 case iL2WhispRing:
7133 case iChargeRing:
7134 case iL2ChargeRing:
7135 case iPerilScroll:
7136 case iWalletL3:
7137 case iQuiverL4:
7138 case iBombBagL4:
7139 case iBracelet:
7140 case iL2Bracelet:
7141 case iOldGlove:
7142 case iL2Ladder:
7143 case iWealthMedal:
7144 case iL2WealthMedal:
7145 case iL3WealthMedal:
7146 198 reset_itembuf(&tempitem, i);
7147 198 strcpy(item_string[i],old_item_string[i]);
7148 198 break;
7149
7150 case iSShield:
7151 9 reset_itembuf(&tempitem, i);
7152 9 strcpy(item_string[i],old_item_string[i]);
7153 9 strcpy(item_string[iShield],old_item_string[iShield]);
7154 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7155 9 break;
7156 }
7157 2304 }
7158
7159
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 5)
7160 {
7161
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7162 {
7163 case iHeartRing:
7164 case iL2HeartRing:
7165 case iL3HeartRing:
7166 case iMagicRing:
7167 case iL2MagicRing:
7168 case iL3MagicRing:
7169 case iL4MagicRing:
7170 63 reset_itembuf(&tempitem, i);
7171 63 strcpy(item_string[i],old_item_string[i]);
7172 63 break;
7173 }
7174 2304 }
7175
7176
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7177 {
7178
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7179 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7180
7181
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7182 {
7183 case iTriforce:
7184 9 tempitem.fam_type=1;
7185 9 break;
7186
7187 case iBigTri:
7188 9 tempitem.fam_type=0;
7189 9 break;
7190
7191 case iBombs:
7192 9 tempitem.fam_type=i_bomb;
7193 9 tempitem.power=4;
7194 9 tempitem.wpn=wBOMB;
7195 9 tempitem.wpn2=wBOOM;
7196 9 tempitem.misc1 = 50;
7197
7198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7199
7200 9 break;
7201
7202 case iSBomb:
7203 9 tempitem.fam_type=i_sbomb;
7204 9 tempitem.power=16;
7205 9 tempitem.wpn=wSBOMB;
7206 9 tempitem.wpn2=wSBOOM;
7207 9 tempitem.misc1 = 50;
7208
7209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7210
7211 9 break;
7212
7213 case iBook:
7214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 113))
7215 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7216
7217 9 break;
7218
7219 case iSArrow:
7220 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7221 9 tempitem.power=4;
7222 9 tempitem.flags|=ITEM_GAMEDATA;
7223 9 tempitem.wpn=wSARROW;
7224 9 break;
7225
7226 case iGArrow:
7227 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7228 9 tempitem.power=8;
7229 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7230 9 tempitem.wpn=wGARROW;
7231 9 break;
7232
7233 case iBrang:
7234 9 tempitem.power=0;
7235 9 tempitem.wpn=wBRANG;
7236 9 tempitem.misc1=36;
7237 9 break;
7238
7239 case iMBrang:
7240 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7241 9 tempitem.power=0;
7242 9 tempitem.wpn=wMBRANG;
7243 9 break;
7244
7245 case iFBrang:
7246 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7247 9 tempitem.power=2;
7248 9 tempitem.wpn=wFBRANG;
7249 9 break;
7250
7251 case iBoots:
7252 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7253 9 tempitem.power=7;
7254 9 break;
7255
7256 case iWand:
7257 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7258 9 tempitem.power=2;
7259 9 tempitem.wpn=wWAND;
7260 9 tempitem.wpn3=wMAGIC;
7261 9 break;
7262
7263 case iBCandle:
7264 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7265 9 tempitem.power=1;
7266 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7267 9 tempitem.wpn3=wFIRE;
7268 9 break;
7269
7270 case iRCandle:
7271 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7272 9 tempitem.power=1;
7273 9 tempitem.wpn3=wFIRE;
7274 9 break;
7275
7276 case iSword:
7277 9 tempitem.power=1;
7278 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7279 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7280 9 tempitem.wpn2=wSWORDSLASH;
7281 9 break;
7282
7283 case iWSword:
7284 9 tempitem.power=2;
7285 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7286 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7287 9 tempitem.wpn2=wWSWORDSLASH;
7288 9 break;
7289
7290 case iMSword:
7291 9 tempitem.power=4;
7292 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7293 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7294 9 tempitem.wpn2=wMSWORDSLASH;
7295 9 break;
7296
7297 case iXSword:
7298 9 tempitem.power=8;
7299 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7300 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7301 9 tempitem.wpn2=wXSWORDSLASH;
7302 9 break;
7303
7304 case iDivineProtection:
7305 9 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7306 9 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7307 9 tempitem.wpn=wDIVINEPROTECTION1A;
7308 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7309 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7310 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7311 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7312 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7313 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7314 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7315 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7316 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7317 9 tempitem.misc1=512;
7318 9 tempitem.cost_amount[0]=64;
7319 9 break;
7320
7321 case iLens:
7322 9 tempitem.misc1=60;
7323 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7324 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7325 9 break;
7326
7327 case iArrow:
7328 9 tempitem.power=2;
7329 9 tempitem.wpn=wARROW;
7330 9 break;
7331
7332 case iHoverBoots:
7333 9 tempitem.misc1=45;
7334 9 tempitem.wpn=iwHover;
7335 9 break;
7336
7337 case iDivineFire:
7338 9 tempitem.power=8;
7339 9 tempitem.wpn=wDIVINEFIRE1A;
7340 9 tempitem.wpn2=wDIVINEFIRE1B;
7341 9 tempitem.wpn3=wDIVINEFIRES1A;
7342 9 tempitem.wpn4=wDIVINEFIRES1B;
7343 9 tempitem.misc1 = 32;
7344 9 tempitem.misc2 = 200;
7345 9 tempitem.cost_amount[0]=32;
7346 9 break;
7347
7348 case iDivineEscape:
7349 9 tempitem.cost_amount[0]=32;
7350 9 break;
7351
7352 case iHookshot:
7353 9 tempitem.power=0;
7354 9 tempitem.flags&=~ITEM_FLAG1;
7355 9 tempitem.wpn=wHSHEAD;
7356 9 tempitem.wpn2=wHSCHAIN_H;
7357 9 tempitem.wpn4=wHSHANDLE;
7358 9 tempitem.wpn3=wHSCHAIN_V;
7359 9 tempitem.misc1=50;
7360 9 tempitem.misc2=100;
7361 9 break;
7362
7363 case iLongshot:
7364 9 tempitem.power=0;
7365 9 tempitem.flags&=~ITEM_FLAG1;
7366 9 tempitem.wpn=wLSHEAD;
7367 9 tempitem.wpn2=wLSCHAIN_H;
7368 9 tempitem.wpn4=wLSHANDLE;
7369 9 tempitem.wpn3=wLSCHAIN_V;
7370 9 tempitem.misc1=99;
7371 9 tempitem.misc2=100;
7372 9 break;
7373
7374 case iHammer:
7375 9 tempitem.power=4;
7376 9 tempitem.wpn=wHAMMER;
7377 9 tempitem.wpn2=iwHammerSmack;
7378 9 break;
7379
7380 case iCByrna:
7381 9 tempitem.power=1;
7382 9 tempitem.wpn=wCBYRNA;
7383 9 tempitem.wpn2=wCBYRNASLASH;
7384 9 tempitem.wpn3=wCBYRNAORB;
7385 9 tempitem.misc1=4;
7386 9 tempitem.misc2=16;
7387 9 tempitem.misc3=1;
7388 9 tempitem.cost_amount[0]=1;
7389 9 break;
7390
7391 case iWhistle:
7392 9 tempitem.wpn=wWIND;
7393 9 tempitem.misc1=3;
7394 9 tempitem.flags|=ITEM_FLAG1;
7395 9 break;
7396
7397 case iBRing:
7398 9 tempitem.power=2;
7399 9 tempitem.misc1=spBLUE;
7400 9 break;
7401
7402 case iRRing:
7403 9 tempitem.power=4;
7404 9 tempitem.misc1=spRED;
7405 9 break;
7406
7407 case iGRing:
7408 9 tempitem.power=8;
7409 9 tempitem.misc1=spGOLD;
7410 9 break;
7411
7412 case iSpinScroll:
7413 9 tempitem.power = 2;
7414 9 tempitem.misc1 = 1;
7415 9 break;
7416
7417 case iL2SpinScroll:
7418 9 tempitem.family=itype_spinscroll2;
7419 9 tempitem.fam_type=1;
7420 9 tempitem.cost_amount[0]=8;
7421 9 tempitem.power=2;
7422 9 tempitem.misc1 = 20;
7423 9 break;
7424
7425 case iQuakeScroll:
7426 9 tempitem.misc1=0x10;
7427 9 tempitem.misc2=64;
7428 9 break;
7429
7430 case iL2QuakeScroll:
7431 9 tempitem.family=itype_quakescroll2;
7432 9 tempitem.fam_type=1;
7433 9 tempitem.power = 2;
7434 9 tempitem.misc1=0x20;
7435 9 tempitem.misc2=192;
7436 9 tempitem.cost_amount[0]=8;
7437 9 break;
7438
7439 case iChargeRing:
7440 9 tempitem.misc1=64;
7441 9 tempitem.misc2=128;
7442 9 break;
7443
7444 case iL2ChargeRing:
7445 9 tempitem.misc1=32;
7446 9 tempitem.misc2=64;
7447 9 break;
7448
7449 case iOldGlove:
7450 9 tempitem.flags |= ITEM_FLAG1;
7451
7452 //fallthrough
7453 case iBombBagL4:
7454 case iWalletL3:
7455 case iQuiverL4:
7456 case iBracelet:
7457 45 tempitem.power = 1;
7458 45 break;
7459
7460 case iL2Bracelet:
7461 9 tempitem.power = 2;
7462 9 break;
7463
7464 case iMKey:
7465 9 tempitem.power=0xFF;
7466 9 tempitem.flags |= ITEM_FLAG1;
7467 9 break;
7468 }
7469 2304 }
7470
7471
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 7)
7472 {
7473
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7474 {
7475 case iStoneAgony:
7476 case iStompBoots:
7477 case iPerilRing:
7478 case iWhimsicalRing:
7479 {
7480 36 reset_itembuf(&tempitem, i);
7481 36 strcpy(item_string[i],old_item_string[i]);
7482 36 break;
7483 }
7484 }
7485 2304 }
7486
7487
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 8) // May 2007: Some corrections.
7488 {
7489
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7490 {
7491 case iMShield:
7492 9 tempitem.misc1|=shFLAME;
7493 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7494
7495
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7496 {
7497 tempitem.misc2 |= shSWORD;
7498 }
7499
7500 // fallthrough
7501 case iShield:
7502 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7503
7504 // fallthrough
7505 case iSShield:
7506 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7507
7508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7509 {
7510 tempitem.misc2 |= shROCK;
7511 }
7512
7513 27 break;
7514
7515 case iWhispRing:
7516 9 tempitem.power=1;
7517 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7518 9 tempitem.misc1 = 3;
7519 9 break;
7520
7521 case iL2WhispRing:
7522 9 tempitem.power=0;
7523 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7524 9 tempitem.misc1 = 3;
7525 9 break;
7526
7527 case iL2Ladder:
7528 case iBow:
7529 case iCByrna:
7530 27 tempitem.power = 1;
7531 27 break;
7532 }
7533 2304 }
7534
7535
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 9 && i==iClock)
7536 {
7537 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7538 9 }
7539
7540 //add the misc flag for bomb
7541
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27648 if(s_version < 10 && tempitem.family == itype_bomb)
7542 {
7543 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7544 9 }
7545
7546
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
27648 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7547 {
7548 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7549 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7550 18 }
7551
7552
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 12) // June 2007: More Misc. attributes.
7553 {
7554
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7555 {
7556 case iFBrang:
7557 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7558
7559 //fallthrough
7560 case iMBrang:
7561 18 tempitem.misc3 |= shSWORD|shMAGIC;
7562
7563 //fallthrough
7564 case iHookshot:
7565 case iLongshot:
7566 //fallthrough
7567 36 tempitem.misc3 |= shFIREBALL;
7568
7569 case iBrang:
7570 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7571 45 break;
7572 }
7573
7574
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7575 {
7576 case itype_hoverboots:
7577 9 tempitem.usesound = WAV_ZN1HOVER;
7578 9 break;
7579
7580 case itype_wand:
7581 9 tempitem.usesound = WAV_WAND;
7582 9 break;
7583
7584 case itype_book:
7585 9 tempitem.usesound = WAV_FIRE;
7586 9 break;
7587
7588 case itype_arrow:
7589 27 tempitem.usesound = WAV_ARROW;
7590 27 break;
7591
7592 case itype_hookshot:
7593 18 tempitem.usesound = WAV_HOOKSHOT;
7594 18 break;
7595
7596 case itype_brang:
7597 27 tempitem.usesound = WAV_BRANG;
7598 27 break;
7599
7600 case itype_shield:
7601 27 tempitem.usesound = WAV_CHINK;
7602 27 break;
7603
7604 case itype_sword:
7605 781 tempitem.usesound = WAV_SWORD;
7606 781 break;
7607
7608 case itype_whistle:
7609 9 tempitem.usesound = WAV_WHISTLE;
7610 9 break;
7611
7612 case itype_hammer:
7613 9 tempitem.usesound = WAV_HAMMER;
7614 9 break;
7615
7616 case itype_divinefire:
7617 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7618 9 break;
7619
7620 case itype_divineescape:
7621 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7622 9 break;
7623
7624 case itype_divineprotection:
7625 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7626 9 break;
7627
7628 case itype_bomb:
7629 case itype_sbomb:
7630 case itype_quakescroll:
7631 case itype_quakescroll2:
7632 36 tempitem.usesound = WAV_BOMB;
7633 36 break;
7634
7635 case itype_spinscroll:
7636 case itype_spinscroll2:
7637 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7638 18 break;
7639 }
7640 2304 }
7641
7642
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 13) // July 2007
7643 {
7644
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7645 {
7646 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7647 9 tempitem.power = 1;
7648 9 tempitem.flags|=ITEM_FLAG1;
7649 9 }
7650
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7651 9 tempitem.flags|=ITEM_FLAG1;
7652
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7653 {
7654 9 tempitem.flags|=ITEM_FLAG1;
7655 9 tempitem.power = 2;
7656 9 }
7657 2304 }
7658
7659
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 14) // August 2007
7660 {
7661
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7662 {
7663 18 tempitem.usesound = WAV_SCALE;
7664
7665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7666 18 tempitem.misc3=50;
7667 18 }
7668
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7669 {
7670 18 tempitem.flags |= ITEM_GAINOLD;
7671 18 }
7672 2304 }
7673
7674
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 17) // November 2007
7675 {
7676
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7677 {
7678 tempitem.wpn3 = wFIRE;
7679 }
7680
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7681 {
7682 9 tempitem.flags|=ITEM_FLAG1;
7683 9 }
7684 2304 }
7685
7686
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 18) // New Year's Eve 2007
7687 {
7688
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7689 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7690
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7691 9 tempitem.misc1 = 768; // Frames until it goes
7692
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7693 {
7694
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7695 {
7696 9 tempitem.misc2 = 1; // Cutscene 1
7697 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7698 9 }
7699 18 }
7700 2304 }
7701
7702
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 19) // January 2008
7703 {
7704
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7705 {
7706 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7707 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7708 9 }
7709 2304 }
7710
7711
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 20) // October 2008
7712 {
7713
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7714 {
7715 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7716 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7717 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7718 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7719 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7720 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7721 9 }
7722 2304 }
7723
7724
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 21) // November 2008
7725 {
7726
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7727 {
7728 tempitem.flags &= ~0x0100;
7729
7730 if(tempitem.family == itype_sword ||
7731 tempitem.family == itype_wand ||
7732 tempitem.family == itype_candle ||
7733 tempitem.family == itype_cbyrna)
7734 {
7735 tempitem.flags |= ITEM_FLAG4;
7736 }
7737 }
7738 2304 }
7739
7740
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 22) // September 2009
7741 {
7742
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7743 {
7744 18 tempitem.misc3 = tempitem.power/2;
7745 18 }
7746 2304 }
7747
7748
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 23) // March 2011
7749 {
7750
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7751 9 tempitem.wpn5 = wFIRE;
7752
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7753 9 tempitem.wpn2 = wFIRE;
7754 2304 }
7755
7756 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7757 // whether it was or not, and a lot of existing quests depended on the
7758 // incorrect behavior.
7759
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 2304 times.
27648 if(s_version < 25) // January 2012
7760 {
7761
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7762 36 tempitem.flags |= 16;
7763
7764
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7765 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7766 2304 }
7767
7768
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7769 {
7770
60/60
✓ Branch 0 taken 6844 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 247 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 129 times.
✓ Branch 5 taken 84 times.
✓ Branch 6 taken 166 times.
✓ Branch 7 taken 165 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 275 times.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 165 times.
✓ Branch 12 taken 256 times.
✓ Branch 13 taken 166 times.
✓ Branch 14 taken 83 times.
✓ Branch 15 taken 166 times.
✓ Branch 16 taken 98 times.
✓ Branch 17 taken 83 times.
✓ Branch 18 taken 252 times.
✓ Branch 19 taken 84 times.
✓ Branch 20 taken 85 times.
✓ Branch 21 taken 166 times.
✓ Branch 22 taken 83 times.
✓ Branch 23 taken 84 times.
✓ Branch 24 taken 83 times.
✓ Branch 25 taken 83 times.
✓ Branch 26 taken 83 times.
✓ Branch 27 taken 98 times.
✓ Branch 28 taken 83 times.
✓ Branch 29 taken 84 times.
✓ Branch 30 taken 83 times.
✓ Branch 31 taken 84 times.
✓ Branch 32 taken 166 times.
✓ Branch 33 taken 332 times.
✓ Branch 34 taken 85 times.
✓ Branch 35 taken 83 times.
✓ Branch 36 taken 150 times.
✓ Branch 37 taken 332 times.
✓ Branch 38 taken 83 times.
✓ Branch 39 taken 83 times.
✓ Branch 40 taken 83 times.
✓ Branch 41 taken 83 times.
✓ Branch 42 taken 83 times.
✓ Branch 43 taken 167 times.
✓ Branch 44 taken 166 times.
✓ Branch 45 taken 83 times.
✓ Branch 46 taken 250 times.
✓ Branch 47 taken 251 times.
✓ Branch 48 taken 336 times.
✓ Branch 49 taken 83 times.
✓ Branch 50 taken 83 times.
✓ Branch 51 taken 83 times.
✓ Branch 52 taken 83 times.
✓ Branch 53 taken 83 times.
✓ Branch 54 taken 84 times.
✓ Branch 55 taken 2230 times.
✓ Branch 56 taken 893 times.
✓ Branch 57 taken 250 times.
✓ Branch 58 taken 1036 times.
✓ Branch 59 taken 2617 times.
21504 switch(tempitem.family)
7771 {
7772 case itype_sword:
7773 {
7774 6844 tempitem.flags &= ~(ITEM_FLAG5);
7775 6844 tempitem.misc3 = 0;
7776 6844 tempitem.misc4 = 0;
7777 6844 tempitem.misc5 = 0;
7778 6844 tempitem.misc6 = 0;
7779 6844 tempitem.misc7 = 0;
7780 6844 tempitem.misc8 = 0;
7781 6844 tempitem.misc9 = 0;
7782 6844 tempitem.misc10 = 0;
7783 6844 tempitem.wpn4 = 0;
7784 6844 tempitem.wpn5 = 0;
7785 6844 tempitem.wpn6 = 0;
7786 6844 tempitem.wpn7 = 0;
7787 6844 tempitem.wpn8 = 0;
7788 6844 tempitem.wpn9 = 0;
7789 6844 tempitem.wpn10 = 0;
7790 6844 break;
7791 }
7792 case itype_brang:
7793 {
7794 250 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7795 250 tempitem.misc2 = 0;
7796 250 tempitem.misc5 = 0;
7797 250 tempitem.misc6 = 0;
7798 250 tempitem.misc7 = 0;
7799 250 tempitem.misc8 = 0;
7800 250 tempitem.misc9 = 0;
7801 250 tempitem.misc10 = 0;
7802 250 tempitem.wpn4 = 0;
7803 250 tempitem.wpn5 = 0;
7804 250 tempitem.wpn6 = 0;
7805 250 tempitem.wpn7 = 0;
7806 250 tempitem.wpn8 = 0;
7807 250 tempitem.wpn9 = 0;
7808 250 tempitem.wpn10 = 0;
7809 250 break;
7810 }
7811 case itype_arrow:
7812 {
7813 247 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7814 247 tempitem.misc2 = 0;
7815 247 tempitem.misc3 = 0;
7816 247 tempitem.misc4 = 0;
7817 247 tempitem.misc5 = 0;
7818 247 tempitem.misc6 = 0;
7819 247 tempitem.misc7 = 0;
7820 247 tempitem.misc8 = 0;
7821 247 tempitem.misc9 = 0;
7822 247 tempitem.misc10 = 0;
7823 247 tempitem.wpn4 = 0;
7824 247 tempitem.wpn5 = 0;
7825 247 tempitem.wpn6 = 0;
7826 247 tempitem.wpn7 = 0;
7827 247 tempitem.wpn8 = 0;
7828 247 tempitem.wpn9 = 0;
7829 247 tempitem.wpn10 = 0;
7830 247 break;
7831 }
7832 case itype_candle:
7833 {
7834 204 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7835 204 tempitem.misc1 = 0;
7836 204 tempitem.misc2 = 0;
7837 204 tempitem.misc3 = 0;
7838 204 tempitem.misc4 = 0;
7839 204 tempitem.misc5 = 0;
7840 204 tempitem.misc6 = 0;
7841 204 tempitem.misc7 = 0;
7842 204 tempitem.misc8 = 0;
7843 204 tempitem.misc9 = 0;
7844 204 tempitem.misc10 = 0;
7845 204 tempitem.wpn4 = 0;
7846 204 tempitem.wpn5 = 0;
7847 204 tempitem.wpn6 = 0;
7848 204 tempitem.wpn7 = 0;
7849 204 tempitem.wpn8 = 0;
7850 204 tempitem.wpn9 = 0;
7851 204 tempitem.wpn10 = 0;
7852 204 break;
7853 }
7854 case itype_whistle:
7855 {
7856 129 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7857 129 tempitem.misc3 = 0;
7858 129 tempitem.misc4 = 0;
7859 129 tempitem.misc5 = 0;
7860 129 tempitem.misc6 = 0;
7861 129 tempitem.misc7 = 0;
7862 129 tempitem.misc8 = 0;
7863 129 tempitem.misc9 = 0;
7864 129 tempitem.misc10 = 0;
7865 129 tempitem.wpn2 = 0;
7866 129 tempitem.wpn3 = 0;
7867 129 tempitem.wpn4 = 0;
7868 129 tempitem.wpn5 = 0;
7869 129 tempitem.wpn6 = 0;
7870 129 tempitem.wpn7 = 0;
7871 129 tempitem.wpn8 = 0;
7872 129 tempitem.wpn9 = 0;
7873 129 tempitem.wpn10 = 0;
7874 129 break;
7875 }
7876 case itype_bait:
7877 {
7878 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7879 84 tempitem.misc2 = 0;
7880 84 tempitem.misc3 = 0;
7881 84 tempitem.misc4 = 0;
7882 84 tempitem.misc5 = 0;
7883 84 tempitem.misc6 = 0;
7884 84 tempitem.misc7 = 0;
7885 84 tempitem.misc8 = 0;
7886 84 tempitem.misc9 = 0;
7887 84 tempitem.misc10 = 0;
7888 84 tempitem.wpn2 = 0;
7889 84 tempitem.wpn3 = 0;
7890 84 tempitem.wpn4 = 0;
7891 84 tempitem.wpn5 = 0;
7892 84 tempitem.wpn6 = 0;
7893 84 tempitem.wpn7 = 0;
7894 84 tempitem.wpn8 = 0;
7895 84 tempitem.wpn9 = 0;
7896 84 tempitem.wpn10 = 0;
7897 84 break;
7898 }
7899 case itype_letter:
7900 {
7901 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7902 166 tempitem.misc1 = 0;
7903 166 tempitem.misc2 = 0;
7904 166 tempitem.misc3 = 0;
7905 166 tempitem.misc4 = 0;
7906 166 tempitem.misc5 = 0;
7907 166 tempitem.misc6 = 0;
7908 166 tempitem.misc7 = 0;
7909 166 tempitem.misc8 = 0;
7910 166 tempitem.misc9 = 0;
7911 166 tempitem.misc10 = 0;
7912 166 tempitem.wpn = 0;
7913 166 tempitem.wpn2 = 0;
7914 166 tempitem.wpn3 = 0;
7915 166 tempitem.wpn4 = 0;
7916 166 tempitem.wpn5 = 0;
7917 166 tempitem.wpn6 = 0;
7918 166 tempitem.wpn7 = 0;
7919 166 tempitem.wpn8 = 0;
7920 166 tempitem.wpn9 = 0;
7921 166 tempitem.wpn10 = 0;
7922 166 break;
7923 }
7924 case itype_potion:
7925 {
7926 165 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7927 165 tempitem.misc3 = 0;
7928 165 tempitem.misc4 = 0;
7929 165 tempitem.misc5 = 0;
7930 165 tempitem.misc6 = 0;
7931 165 tempitem.misc7 = 0;
7932 165 tempitem.misc8 = 0;
7933 165 tempitem.misc9 = 0;
7934 165 tempitem.misc10 = 0;
7935 165 tempitem.wpn = 0;
7936 165 tempitem.wpn2 = 0;
7937 165 tempitem.wpn3 = 0;
7938 165 tempitem.wpn4 = 0;
7939 165 tempitem.wpn5 = 0;
7940 165 tempitem.wpn6 = 0;
7941 165 tempitem.wpn7 = 0;
7942 165 tempitem.wpn8 = 0;
7943 165 tempitem.wpn9 = 0;
7944 165 tempitem.wpn10 = 0;
7945 165 break;
7946 }
7947 case itype_wand:
7948 {
7949 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7950 98 tempitem.misc1 = 0;
7951 98 tempitem.misc2 = 0;
7952 98 tempitem.misc3 = 0;
7953 98 tempitem.misc4 = 0;
7954 98 tempitem.misc5 = 0;
7955 98 tempitem.misc6 = 0;
7956 98 tempitem.misc7 = 0;
7957 98 tempitem.misc8 = 0;
7958 98 tempitem.misc9 = 0;
7959 98 tempitem.misc10 = 0;
7960 98 tempitem.wpn4 = 0;
7961 98 tempitem.wpn5 = 0;
7962 98 tempitem.wpn6 = 0;
7963 98 tempitem.wpn7 = 0;
7964 98 tempitem.wpn8 = 0;
7965 98 tempitem.wpn9 = 0;
7966 98 tempitem.wpn10 = 0;
7967 98 break;
7968 }
7969 case itype_ring:
7970 {
7971 275 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7972 275 tempitem.misc2 = 0;
7973 275 tempitem.misc3 = 0;
7974 275 tempitem.misc4 = 0;
7975 275 tempitem.misc5 = 0;
7976 275 tempitem.misc6 = 0;
7977 275 tempitem.misc7 = 0;
7978 275 tempitem.misc8 = 0;
7979 275 tempitem.misc9 = 0;
7980 275 tempitem.misc10 = 0;
7981 275 tempitem.wpn = 0;
7982 275 tempitem.wpn2 = 0;
7983 275 tempitem.wpn3 = 0;
7984 275 tempitem.wpn4 = 0;
7985 275 tempitem.wpn5 = 0;
7986 275 tempitem.wpn6 = 0;
7987 275 tempitem.wpn7 = 0;
7988 275 tempitem.wpn8 = 0;
7989 275 tempitem.wpn9 = 0;
7990 275 tempitem.wpn10 = 0;
7991 275 break;
7992 }
7993 case itype_wallet:
7994 {
7995 249 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7996 249 tempitem.misc3 = 0;
7997 249 tempitem.misc4 = 0;
7998 249 tempitem.misc5 = 0;
7999 249 tempitem.misc6 = 0;
8000 249 tempitem.misc7 = 0;
8001 249 tempitem.misc8 = 0;
8002 249 tempitem.misc9 = 0;
8003 249 tempitem.misc10 = 0;
8004 249 tempitem.wpn = 0;
8005 249 tempitem.wpn2 = 0;
8006 249 tempitem.wpn3 = 0;
8007 249 tempitem.wpn4 = 0;
8008 249 tempitem.wpn5 = 0;
8009 249 tempitem.wpn6 = 0;
8010 249 tempitem.wpn7 = 0;
8011 249 tempitem.wpn8 = 0;
8012 249 tempitem.wpn9 = 0;
8013 249 tempitem.wpn10 = 0;
8014 249 break;
8015 }
8016 case itype_amulet:
8017 {
8018 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8019 165 tempitem.misc1 = 0;
8020 165 tempitem.misc2 = 0;
8021 165 tempitem.misc3 = 0;
8022 165 tempitem.misc4 = 0;
8023 165 tempitem.misc5 = 0;
8024 165 tempitem.misc6 = 0;
8025 165 tempitem.misc7 = 0;
8026 165 tempitem.misc8 = 0;
8027 165 tempitem.misc9 = 0;
8028 165 tempitem.misc10 = 0;
8029 165 tempitem.wpn = 0;
8030 165 tempitem.wpn2 = 0;
8031 165 tempitem.wpn3 = 0;
8032 165 tempitem.wpn4 = 0;
8033 165 tempitem.wpn5 = 0;
8034 165 tempitem.wpn6 = 0;
8035 165 tempitem.wpn7 = 0;
8036 165 tempitem.wpn8 = 0;
8037 165 tempitem.wpn9 = 0;
8038 165 tempitem.wpn10 = 0;
8039 165 break;
8040 }
8041 case itype_shield:
8042 {
8043 256 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8044 256 tempitem.misc3 = 0;
8045 256 tempitem.misc4 = 0;
8046 256 tempitem.misc5 = 0;
8047 256 tempitem.misc6 = 0;
8048 256 tempitem.misc7 = 0;
8049 256 tempitem.misc8 = 0;
8050 256 tempitem.misc9 = 0;
8051 256 tempitem.misc10 = 0;
8052 256 tempitem.wpn = 0;
8053 256 tempitem.wpn2 = 0;
8054 256 tempitem.wpn3 = 0;
8055 256 tempitem.wpn4 = 0;
8056 256 tempitem.wpn5 = 0;
8057 256 tempitem.wpn6 = 0;
8058 256 tempitem.wpn7 = 0;
8059 256 tempitem.wpn8 = 0;
8060 256 tempitem.wpn9 = 0;
8061 256 tempitem.wpn10 = 0;
8062 256 break;
8063 }
8064 case itype_bow:
8065 {
8066 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8067 166 tempitem.misc1 = 0;
8068 166 tempitem.misc2 = 0;
8069 166 tempitem.misc3 = 0;
8070 166 tempitem.misc4 = 0;
8071 166 tempitem.misc5 = 0;
8072 166 tempitem.misc6 = 0;
8073 166 tempitem.misc7 = 0;
8074 166 tempitem.misc8 = 0;
8075 166 tempitem.misc9 = 0;
8076 166 tempitem.misc10 = 0;
8077 166 tempitem.wpn = 0;
8078 166 tempitem.wpn2 = 0;
8079 166 tempitem.wpn3 = 0;
8080 166 tempitem.wpn4 = 0;
8081 166 tempitem.wpn5 = 0;
8082 166 tempitem.wpn6 = 0;
8083 166 tempitem.wpn7 = 0;
8084 166 tempitem.wpn8 = 0;
8085 166 tempitem.wpn9 = 0;
8086 166 tempitem.wpn10 = 0;
8087 166 break;
8088 }
8089 case itype_raft:
8090 {
8091 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8092 83 tempitem.misc1 = 0;
8093 83 tempitem.misc2 = 0;
8094 83 tempitem.misc3 = 0;
8095 83 tempitem.misc4 = 0;
8096 83 tempitem.misc5 = 0;
8097 83 tempitem.misc6 = 0;
8098 83 tempitem.misc7 = 0;
8099 83 tempitem.misc8 = 0;
8100 83 tempitem.misc9 = 0;
8101 83 tempitem.misc10 = 0;
8102 83 tempitem.wpn = 0;
8103 83 tempitem.wpn2 = 0;
8104 83 tempitem.wpn3 = 0;
8105 83 tempitem.wpn4 = 0;
8106 83 tempitem.wpn5 = 0;
8107 83 tempitem.wpn6 = 0;
8108 83 tempitem.wpn7 = 0;
8109 83 tempitem.wpn8 = 0;
8110 83 tempitem.wpn9 = 0;
8111 83 tempitem.wpn10 = 0;
8112 83 break;
8113 }
8114 case itype_ladder:
8115 {
8116 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8117 166 tempitem.misc1 = 0;
8118 166 tempitem.misc2 = 0;
8119 166 tempitem.misc3 = 0;
8120 166 tempitem.misc4 = 0;
8121 166 tempitem.misc5 = 0;
8122 166 tempitem.misc6 = 0;
8123 166 tempitem.misc7 = 0;
8124 166 tempitem.misc8 = 0;
8125 166 tempitem.misc9 = 0;
8126 166 tempitem.misc10 = 0;
8127 166 tempitem.wpn = 0;
8128 166 tempitem.wpn2 = 0;
8129 166 tempitem.wpn3 = 0;
8130 166 tempitem.wpn4 = 0;
8131 166 tempitem.wpn5 = 0;
8132 166 tempitem.wpn6 = 0;
8133 166 tempitem.wpn7 = 0;
8134 166 tempitem.wpn8 = 0;
8135 166 tempitem.wpn9 = 0;
8136 166 tempitem.wpn10 = 0;
8137 166 break;
8138 }
8139 case itype_book:
8140 {
8141 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8142 98 tempitem.misc1 = 0;
8143 98 tempitem.misc2 = 0;
8144 98 tempitem.misc3 = 0;
8145 98 tempitem.misc4 = 0;
8146 98 tempitem.misc5 = 0;
8147 98 tempitem.misc6 = 0;
8148 98 tempitem.misc7 = 0;
8149 98 tempitem.misc8 = 0;
8150 98 tempitem.misc9 = 0;
8151 98 tempitem.misc10 = 0;
8152 98 tempitem.wpn3 = 0;
8153 98 tempitem.wpn4 = 0;
8154 98 tempitem.wpn5 = 0;
8155 98 tempitem.wpn6 = 0;
8156 98 tempitem.wpn7 = 0;
8157 98 tempitem.wpn8 = 0;
8158 98 tempitem.wpn9 = 0;
8159 98 tempitem.wpn10 = 0;
8160 98 break;
8161 }
8162 case itype_magickey:
8163 {
8164 83 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8165 83 tempitem.misc1 = 0;
8166 83 tempitem.misc2 = 0;
8167 83 tempitem.misc3 = 0;
8168 83 tempitem.misc4 = 0;
8169 83 tempitem.misc5 = 0;
8170 83 tempitem.misc6 = 0;
8171 83 tempitem.misc7 = 0;
8172 83 tempitem.misc8 = 0;
8173 83 tempitem.misc9 = 0;
8174 83 tempitem.misc10 = 0;
8175 83 tempitem.wpn = 0;
8176 83 tempitem.wpn2 = 0;
8177 83 tempitem.wpn3 = 0;
8178 83 tempitem.wpn4 = 0;
8179 83 tempitem.wpn5 = 0;
8180 83 tempitem.wpn6 = 0;
8181 83 tempitem.wpn7 = 0;
8182 83 tempitem.wpn8 = 0;
8183 83 tempitem.wpn9 = 0;
8184 83 tempitem.wpn10 = 0;
8185 83 break;
8186 }
8187 case itype_bracelet:
8188 {
8189 252 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8190 252 tempitem.misc1 = 0;
8191 252 tempitem.misc2 = 0;
8192 252 tempitem.misc3 = 0;
8193 252 tempitem.misc4 = 0;
8194 252 tempitem.misc5 = 0;
8195 252 tempitem.misc6 = 0;
8196 252 tempitem.misc7 = 0;
8197 252 tempitem.misc8 = 0;
8198 252 tempitem.misc9 = 0;
8199 252 tempitem.misc10 = 0;
8200 252 tempitem.wpn = 0;
8201 252 tempitem.wpn2 = 0;
8202 252 tempitem.wpn3 = 0;
8203 252 tempitem.wpn4 = 0;
8204 252 tempitem.wpn5 = 0;
8205 252 tempitem.wpn6 = 0;
8206 252 tempitem.wpn7 = 0;
8207 252 tempitem.wpn8 = 0;
8208 252 tempitem.wpn9 = 0;
8209 252 tempitem.wpn10 = 0;
8210 252 break;
8211 }
8212 case itype_flippers:
8213 {
8214 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8215 84 tempitem.misc1 = 0;
8216 84 tempitem.misc2 = 0;
8217 84 tempitem.misc3 = 0;
8218 84 tempitem.misc4 = 0;
8219 84 tempitem.misc5 = 0;
8220 84 tempitem.misc6 = 0;
8221 84 tempitem.misc7 = 0;
8222 84 tempitem.misc8 = 0;
8223 84 tempitem.misc9 = 0;
8224 84 tempitem.misc10 = 0;
8225 84 tempitem.wpn = 0;
8226 84 tempitem.wpn2 = 0;
8227 84 tempitem.wpn3 = 0;
8228 84 tempitem.wpn4 = 0;
8229 84 tempitem.wpn5 = 0;
8230 84 tempitem.wpn6 = 0;
8231 84 tempitem.wpn7 = 0;
8232 84 tempitem.wpn8 = 0;
8233 84 tempitem.wpn9 = 0;
8234 84 tempitem.wpn10 = 0;
8235 84 break;
8236 }
8237 case itype_boots:
8238 {
8239 85 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8240 85 tempitem.misc1 = 0;
8241 85 tempitem.misc2 = 0;
8242 85 tempitem.misc3 = 0;
8243 85 tempitem.misc4 = 0;
8244 85 tempitem.misc5 = 0;
8245 85 tempitem.misc6 = 0;
8246 85 tempitem.misc7 = 0;
8247 85 tempitem.misc8 = 0;
8248 85 tempitem.misc9 = 0;
8249 85 tempitem.misc10 = 0;
8250 85 tempitem.wpn = 0;
8251 85 tempitem.wpn2 = 0;
8252 85 tempitem.wpn3 = 0;
8253 85 tempitem.wpn4 = 0;
8254 85 tempitem.wpn5 = 0;
8255 85 tempitem.wpn6 = 0;
8256 85 tempitem.wpn7 = 0;
8257 85 tempitem.wpn8 = 0;
8258 85 tempitem.wpn9 = 0;
8259 85 tempitem.wpn10 = 0;
8260 85 break;
8261 }
8262 case itype_hookshot:
8263 {
8264 166 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8265 166 tempitem.misc5 = 0;
8266 166 tempitem.misc6 = 0;
8267 166 tempitem.misc7 = 0;
8268 166 tempitem.misc8 = 0;
8269 166 tempitem.misc9 = 0;
8270 166 tempitem.misc10 = 0;
8271 166 tempitem.wpn5 = 0;
8272 166 tempitem.wpn6 = 0;
8273 166 tempitem.wpn7 = 0;
8274 166 tempitem.wpn8 = 0;
8275 166 tempitem.wpn9 = 0;
8276 166 tempitem.wpn10 = 0;
8277 166 break;
8278 }
8279 case itype_lens:
8280 {
8281 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8282 83 tempitem.misc2 = 0;
8283 83 tempitem.misc3 = 0;
8284 83 tempitem.misc4 = 0;
8285 83 tempitem.misc5 = 0;
8286 83 tempitem.misc6 = 0;
8287 83 tempitem.misc7 = 0;
8288 83 tempitem.misc8 = 0;
8289 83 tempitem.misc9 = 0;
8290 83 tempitem.misc10 = 0;
8291 83 tempitem.wpn = 0;
8292 83 tempitem.wpn2 = 0;
8293 83 tempitem.wpn3 = 0;
8294 83 tempitem.wpn4 = 0;
8295 83 tempitem.wpn5 = 0;
8296 83 tempitem.wpn6 = 0;
8297 83 tempitem.wpn7 = 0;
8298 83 tempitem.wpn8 = 0;
8299 83 tempitem.wpn9 = 0;
8300 83 tempitem.wpn10 = 0;
8301 83 break;
8302 }
8303 case itype_hammer:
8304 {
8305 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8306 84 tempitem.misc1 = 0;
8307 84 tempitem.misc2 = 0;
8308 84 tempitem.misc3 = 0;
8309 84 tempitem.misc4 = 0;
8310 84 tempitem.misc5 = 0;
8311 84 tempitem.misc6 = 0;
8312 84 tempitem.misc7 = 0;
8313 84 tempitem.misc8 = 0;
8314 84 tempitem.misc9 = 0;
8315 84 tempitem.misc10 = 0;
8316 84 tempitem.wpn3 = 0;
8317 84 tempitem.wpn4 = 0;
8318 84 tempitem.wpn5 = 0;
8319 84 tempitem.wpn6 = 0;
8320 84 tempitem.wpn7 = 0;
8321 84 tempitem.wpn8 = 0;
8322 84 tempitem.wpn9 = 0;
8323 84 tempitem.wpn10 = 0;
8324 84 break;
8325 }
8326 case itype_divinefire:
8327 {
8328 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8329 83 tempitem.misc3 = 0;
8330 83 tempitem.misc4 = 0;
8331 83 tempitem.misc5 = 0;
8332 83 tempitem.misc6 = 0;
8333 83 tempitem.misc7 = 0;
8334 83 tempitem.misc8 = 0;
8335 83 tempitem.misc9 = 0;
8336 83 tempitem.misc10 = 0;
8337 83 tempitem.wpn6 = 0;
8338 83 tempitem.wpn7 = 0;
8339 83 tempitem.wpn8 = 0;
8340 83 tempitem.wpn9 = 0;
8341 83 tempitem.wpn10 = 0;
8342 83 break;
8343 }
8344 case itype_divineescape:
8345 {
8346 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8347 83 tempitem.misc2 = 0;
8348 83 tempitem.misc3 = 0;
8349 83 tempitem.misc4 = 0;
8350 83 tempitem.misc5 = 0;
8351 83 tempitem.misc6 = 0;
8352 83 tempitem.misc7 = 0;
8353 83 tempitem.misc8 = 0;
8354 83 tempitem.misc9 = 0;
8355 83 tempitem.misc10 = 0;
8356 83 tempitem.wpn = 0;
8357 83 tempitem.wpn2 = 0;
8358 83 tempitem.wpn3 = 0;
8359 83 tempitem.wpn4 = 0;
8360 83 tempitem.wpn5 = 0;
8361 83 tempitem.wpn6 = 0;
8362 83 tempitem.wpn7 = 0;
8363 83 tempitem.wpn8 = 0;
8364 83 tempitem.wpn9 = 0;
8365 83 tempitem.wpn10 = 0;
8366 83 break;
8367 }
8368 case itype_divineprotection:
8369 {
8370 83 tempitem.flags &= ~ (ITEM_FLAG5);
8371 83 tempitem.misc2 = 0;
8372 83 tempitem.misc3 = 0;
8373 83 tempitem.misc4 = 0;
8374 83 tempitem.misc5 = 0;
8375 83 tempitem.misc6 = 0;
8376 83 tempitem.misc7 = 0;
8377 83 tempitem.misc8 = 0;
8378 83 tempitem.misc9 = 0;
8379 83 tempitem.misc10 = 0;
8380 83 break;
8381 }
8382 case itype_bomb:
8383 {
8384 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8385 98 tempitem.misc4 = 0;
8386 98 tempitem.misc5 = 0;
8387 98 tempitem.misc6 = 0;
8388 98 tempitem.misc7 = 0;
8389 98 tempitem.misc8 = 0;
8390 98 tempitem.misc9 = 0;
8391 98 tempitem.misc10 = 0;
8392 98 tempitem.wpn3 = 0;
8393 98 tempitem.wpn4 = 0;
8394 98 tempitem.wpn5 = 0;
8395 98 tempitem.wpn6 = 0;
8396 98 tempitem.wpn7 = 0;
8397 98 tempitem.wpn8 = 0;
8398 98 tempitem.wpn9 = 0;
8399 98 tempitem.wpn10 = 0;
8400 98 break;
8401 }
8402 case itype_sbomb:
8403 {
8404 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8405 83 tempitem.misc4 = 0;
8406 83 tempitem.misc5 = 0;
8407 83 tempitem.misc6 = 0;
8408 83 tempitem.misc7 = 0;
8409 83 tempitem.misc8 = 0;
8410 83 tempitem.misc9 = 0;
8411 83 tempitem.misc10 = 0;
8412 83 tempitem.wpn3 = 0;
8413 83 tempitem.wpn4 = 0;
8414 83 tempitem.wpn5 = 0;
8415 83 tempitem.wpn6 = 0;
8416 83 tempitem.wpn7 = 0;
8417 83 tempitem.wpn8 = 0;
8418 83 tempitem.wpn9 = 0;
8419 83 tempitem.wpn10 = 0;
8420 83 break;
8421 }
8422 case itype_clock:
8423 {
8424 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8425 84 tempitem.misc2 = 0;
8426 84 tempitem.misc3 = 0;
8427 84 tempitem.misc4 = 0;
8428 84 tempitem.misc5 = 0;
8429 84 tempitem.misc6 = 0;
8430 84 tempitem.misc7 = 0;
8431 84 tempitem.misc8 = 0;
8432 84 tempitem.misc9 = 0;
8433 84 tempitem.misc10 = 0;
8434 84 tempitem.wpn = 0;
8435 84 tempitem.wpn2 = 0;
8436 84 tempitem.wpn3 = 0;
8437 84 tempitem.wpn4 = 0;
8438 84 tempitem.wpn5 = 0;
8439 84 tempitem.wpn6 = 0;
8440 84 tempitem.wpn7 = 0;
8441 84 tempitem.wpn8 = 0;
8442 84 tempitem.wpn9 = 0;
8443 84 tempitem.wpn10 = 0;
8444 84 break;
8445 }
8446 case itype_key:
8447 {
8448 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8449 83 tempitem.misc1 = 0;
8450 83 tempitem.misc2 = 0;
8451 83 tempitem.misc3 = 0;
8452 83 tempitem.misc4 = 0;
8453 83 tempitem.misc5 = 0;
8454 83 tempitem.misc6 = 0;
8455 83 tempitem.misc7 = 0;
8456 83 tempitem.misc8 = 0;
8457 83 tempitem.misc9 = 0;
8458 83 tempitem.misc10 = 0;
8459 83 tempitem.wpn = 0;
8460 83 tempitem.wpn2 = 0;
8461 83 tempitem.wpn3 = 0;
8462 83 tempitem.wpn4 = 0;
8463 83 tempitem.wpn5 = 0;
8464 83 tempitem.wpn6 = 0;
8465 83 tempitem.wpn7 = 0;
8466 83 tempitem.wpn8 = 0;
8467 83 tempitem.wpn9 = 0;
8468 83 tempitem.wpn10 = 0;
8469 83 break;
8470 }
8471 case itype_magiccontainer:
8472 {
8473 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8474 84 tempitem.misc1 = 0;
8475 84 tempitem.misc2 = 0;
8476 84 tempitem.misc3 = 0;
8477 84 tempitem.misc4 = 0;
8478 84 tempitem.misc5 = 0;
8479 84 tempitem.misc6 = 0;
8480 84 tempitem.misc7 = 0;
8481 84 tempitem.misc8 = 0;
8482 84 tempitem.misc9 = 0;
8483 84 tempitem.misc10 = 0;
8484 84 tempitem.wpn = 0;
8485 84 tempitem.wpn2 = 0;
8486 84 tempitem.wpn3 = 0;
8487 84 tempitem.wpn4 = 0;
8488 84 tempitem.wpn5 = 0;
8489 84 tempitem.wpn6 = 0;
8490 84 tempitem.wpn7 = 0;
8491 84 tempitem.wpn8 = 0;
8492 84 tempitem.wpn9 = 0;
8493 84 tempitem.wpn10 = 0;
8494 84 break;
8495 }
8496 case itype_triforcepiece:
8497 {
8498 166 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8499 166 tempitem.misc3 = 0;
8500 166 tempitem.misc4 = 0;
8501 166 tempitem.misc5 = 0;
8502 166 tempitem.misc6 = 0;
8503 166 tempitem.misc7 = 0;
8504 166 tempitem.misc8 = 0;
8505 166 tempitem.misc9 = 0;
8506 166 tempitem.misc10 = 0;
8507 166 tempitem.wpn = 0;
8508 166 tempitem.wpn2 = 0;
8509 166 tempitem.wpn3 = 0;
8510 166 tempitem.wpn4 = 0;
8511 166 tempitem.wpn5 = 0;
8512 166 tempitem.wpn6 = 0;
8513 166 tempitem.wpn7 = 0;
8514 166 tempitem.wpn8 = 0;
8515 166 tempitem.wpn9 = 0;
8516 166 tempitem.wpn10 = 0;
8517 166 break;
8518 }
8519 case itype_map: case itype_compass: case itype_bosskey:
8520 {
8521 250 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8522 250 tempitem.misc1 = 0;
8523 250 tempitem.misc2 = 0;
8524 250 tempitem.misc3 = 0;
8525 250 tempitem.misc4 = 0;
8526 250 tempitem.misc5 = 0;
8527 250 tempitem.misc6 = 0;
8528 250 tempitem.misc7 = 0;
8529 250 tempitem.misc8 = 0;
8530 250 tempitem.misc9 = 0;
8531 250 tempitem.misc10 = 0;
8532 250 tempitem.wpn = 0;
8533 250 tempitem.wpn2 = 0;
8534 250 tempitem.wpn3 = 0;
8535 250 tempitem.wpn4 = 0;
8536 250 tempitem.wpn5 = 0;
8537 250 tempitem.wpn6 = 0;
8538 250 tempitem.wpn7 = 0;
8539 250 tempitem.wpn8 = 0;
8540 250 tempitem.wpn9 = 0;
8541 250 tempitem.wpn10 = 0;
8542 250 break;
8543 }
8544 case itype_quiver:
8545 {
8546 332 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8547 332 tempitem.misc3 = 0;
8548 332 tempitem.misc4 = 0;
8549 332 tempitem.misc5 = 0;
8550 332 tempitem.misc6 = 0;
8551 332 tempitem.misc7 = 0;
8552 332 tempitem.misc8 = 0;
8553 332 tempitem.misc9 = 0;
8554 332 tempitem.misc10 = 0;
8555 332 tempitem.wpn = 0;
8556 332 tempitem.wpn2 = 0;
8557 332 tempitem.wpn3 = 0;
8558 332 tempitem.wpn4 = 0;
8559 332 tempitem.wpn5 = 0;
8560 332 tempitem.wpn6 = 0;
8561 332 tempitem.wpn7 = 0;
8562 332 tempitem.wpn8 = 0;
8563 332 tempitem.wpn9 = 0;
8564 332 tempitem.wpn10 = 0;
8565 332 break;
8566 }
8567 case itype_lkey:
8568 {
8569 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8570 85 tempitem.misc1 = 0;
8571 85 tempitem.misc2 = 0;
8572 85 tempitem.misc3 = 0;
8573 85 tempitem.misc4 = 0;
8574 85 tempitem.misc5 = 0;
8575 85 tempitem.misc6 = 0;
8576 85 tempitem.misc7 = 0;
8577 85 tempitem.misc8 = 0;
8578 85 tempitem.misc9 = 0;
8579 85 tempitem.misc10 = 0;
8580 85 tempitem.wpn = 0;
8581 85 tempitem.wpn2 = 0;
8582 85 tempitem.wpn3 = 0;
8583 85 tempitem.wpn4 = 0;
8584 85 tempitem.wpn5 = 0;
8585 85 tempitem.wpn6 = 0;
8586 85 tempitem.wpn7 = 0;
8587 85 tempitem.wpn8 = 0;
8588 85 tempitem.wpn9 = 0;
8589 85 tempitem.wpn10 = 0;
8590 85 break;
8591 }
8592 case itype_cbyrna:
8593 {
8594 83 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8595 83 tempitem.misc4 = 0;
8596 83 tempitem.misc5 = 0;
8597 83 tempitem.misc6 = 0;
8598 83 tempitem.misc7 = 0;
8599 83 tempitem.misc8 = 0;
8600 83 tempitem.misc9 = 0;
8601 83 tempitem.misc10 = 0;
8602 83 tempitem.wpn6 = 0;
8603 83 tempitem.wpn7 = 0;
8604 83 tempitem.wpn8 = 0;
8605 83 tempitem.wpn9 = 0;
8606 83 tempitem.wpn10 = 0;
8607 83 break;
8608 }
8609 case itype_rupee: case itype_arrowammo:
8610 {
8611 1036 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8612 1036 tempitem.misc1 = 0;
8613 1036 tempitem.misc2 = 0;
8614 1036 tempitem.misc3 = 0;
8615 1036 tempitem.misc4 = 0;
8616 1036 tempitem.misc5 = 0;
8617 1036 tempitem.misc6 = 0;
8618 1036 tempitem.misc7 = 0;
8619 1036 tempitem.misc8 = 0;
8620 1036 tempitem.misc9 = 0;
8621 1036 tempitem.misc10 = 0;
8622 1036 tempitem.wpn = 0;
8623 1036 tempitem.wpn2 = 0;
8624 1036 tempitem.wpn3 = 0;
8625 1036 tempitem.wpn4 = 0;
8626 1036 tempitem.wpn5 = 0;
8627 1036 tempitem.wpn6 = 0;
8628 1036 tempitem.wpn7 = 0;
8629 1036 tempitem.wpn8 = 0;
8630 1036 tempitem.wpn9 = 0;
8631 1036 tempitem.wpn10 = 0;
8632 1036 break;
8633 }
8634 case itype_fairy:
8635 {
8636 150 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8637 150 tempitem.misc4 = 0;
8638 150 tempitem.misc5 = 0;
8639 150 tempitem.misc6 = 0;
8640 150 tempitem.misc7 = 0;
8641 150 tempitem.misc8 = 0;
8642 150 tempitem.misc9 = 0;
8643 150 tempitem.misc10 = 0;
8644 150 tempitem.wpn = 0;
8645 150 tempitem.wpn2 = 0;
8646 150 tempitem.wpn3 = 0;
8647 150 tempitem.wpn4 = 0;
8648 150 tempitem.wpn5 = 0;
8649 150 tempitem.wpn6 = 0;
8650 150 tempitem.wpn7 = 0;
8651 150 tempitem.wpn8 = 0;
8652 150 tempitem.wpn9 = 0;
8653 150 tempitem.wpn10 = 0;
8654 150 break;
8655 }
8656 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8657 {
8658 893 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8659 893 tempitem.misc1 = 0;
8660 893 tempitem.misc2 = 0;
8661 893 tempitem.misc3 = 0;
8662 893 tempitem.misc4 = 0;
8663 893 tempitem.misc5 = 0;
8664 893 tempitem.misc6 = 0;
8665 893 tempitem.misc7 = 0;
8666 893 tempitem.misc8 = 0;
8667 893 tempitem.misc9 = 0;
8668 893 tempitem.misc10 = 0;
8669 893 tempitem.wpn = 0;
8670 893 tempitem.wpn2 = 0;
8671 893 tempitem.wpn3 = 0;
8672 893 tempitem.wpn4 = 0;
8673 893 tempitem.wpn5 = 0;
8674 893 tempitem.wpn6 = 0;
8675 893 tempitem.wpn7 = 0;
8676 893 tempitem.wpn8 = 0;
8677 893 tempitem.wpn9 = 0;
8678 893 tempitem.wpn10 = 0;
8679 893 break;
8680 }
8681 case itype_bombbag:
8682 {
8683 332 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8684 332 tempitem.misc3 = 0;
8685 332 tempitem.misc4 = 0;
8686 332 tempitem.misc5 = 0;
8687 332 tempitem.misc6 = 0;
8688 332 tempitem.misc7 = 0;
8689 332 tempitem.misc8 = 0;
8690 332 tempitem.misc9 = 0;
8691 332 tempitem.misc10 = 0;
8692 332 tempitem.wpn = 0;
8693 332 tempitem.wpn2 = 0;
8694 332 tempitem.wpn3 = 0;
8695 332 tempitem.wpn4 = 0;
8696 332 tempitem.wpn5 = 0;
8697 332 tempitem.wpn6 = 0;
8698 332 tempitem.wpn7 = 0;
8699 332 tempitem.wpn8 = 0;
8700 332 tempitem.wpn9 = 0;
8701 332 tempitem.wpn10 = 0;
8702 332 break;
8703 }
8704 case itype_rocs:
8705 {
8706 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8707 83 tempitem.misc1 = 0;
8708 83 tempitem.misc2 = 0;
8709 83 tempitem.misc3 = 0;
8710 83 tempitem.misc4 = 0;
8711 83 tempitem.misc5 = 0;
8712 83 tempitem.misc6 = 0;
8713 83 tempitem.misc7 = 0;
8714 83 tempitem.misc8 = 0;
8715 83 tempitem.misc9 = 0;
8716 83 tempitem.misc10 = 0;
8717 83 tempitem.wpn = 0;
8718 83 tempitem.wpn2 = 0;
8719 83 tempitem.wpn3 = 0;
8720 83 tempitem.wpn4 = 0;
8721 83 tempitem.wpn5 = 0;
8722 83 tempitem.wpn6 = 0;
8723 83 tempitem.wpn7 = 0;
8724 83 tempitem.wpn8 = 0;
8725 83 tempitem.wpn9 = 0;
8726 83 tempitem.wpn10 = 0;
8727 83 break;
8728 }
8729 case itype_hoverboots:
8730 {
8731 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8732 83 tempitem.misc2 = 0;
8733 83 tempitem.misc3 = 0;
8734 83 tempitem.misc4 = 0;
8735 83 tempitem.misc5 = 0;
8736 83 tempitem.misc6 = 0;
8737 83 tempitem.misc7 = 0;
8738 83 tempitem.misc8 = 0;
8739 83 tempitem.misc9 = 0;
8740 83 tempitem.misc10 = 0;
8741 83 tempitem.wpn2 = 0;
8742 83 tempitem.wpn3 = 0;
8743 83 tempitem.wpn4 = 0;
8744 83 tempitem.wpn5 = 0;
8745 83 tempitem.wpn6 = 0;
8746 83 tempitem.wpn7 = 0;
8747 83 tempitem.wpn8 = 0;
8748 83 tempitem.wpn9 = 0;
8749 83 tempitem.wpn10 = 0;
8750 83 break;
8751 }
8752 case itype_spinscroll:
8753 {
8754 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8755 83 tempitem.misc2 = 0;
8756 83 tempitem.misc3 = 0;
8757 83 tempitem.misc4 = 0;
8758 83 tempitem.misc5 = 0;
8759 83 tempitem.misc6 = 0;
8760 83 tempitem.misc7 = 0;
8761 83 tempitem.misc8 = 0;
8762 83 tempitem.misc9 = 0;
8763 83 tempitem.misc10 = 0;
8764 83 tempitem.wpn = 0;
8765 83 tempitem.wpn2 = 0;
8766 83 tempitem.wpn3 = 0;
8767 83 tempitem.wpn4 = 0;
8768 83 tempitem.wpn5 = 0;
8769 83 tempitem.wpn6 = 0;
8770 83 tempitem.wpn7 = 0;
8771 83 tempitem.wpn8 = 0;
8772 83 tempitem.wpn9 = 0;
8773 83 tempitem.wpn10 = 0;
8774 83 break;
8775 }
8776 case itype_crossscroll:
8777 {
8778 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8779 83 tempitem.misc1 = 0;
8780 83 tempitem.misc2 = 0;
8781 83 tempitem.misc3 = 0;
8782 83 tempitem.misc4 = 0;
8783 83 tempitem.misc5 = 0;
8784 83 tempitem.misc6 = 0;
8785 83 tempitem.misc7 = 0;
8786 83 tempitem.misc8 = 0;
8787 83 tempitem.misc9 = 0;
8788 83 tempitem.misc10 = 0;
8789 83 tempitem.wpn = 0;
8790 83 tempitem.wpn2 = 0;
8791 83 tempitem.wpn3 = 0;
8792 83 tempitem.wpn4 = 0;
8793 83 tempitem.wpn5 = 0;
8794 83 tempitem.wpn6 = 0;
8795 83 tempitem.wpn7 = 0;
8796 83 tempitem.wpn8 = 0;
8797 83 tempitem.wpn9 = 0;
8798 83 tempitem.wpn10 = 0;
8799 83 break;
8800 }
8801 case itype_quakescroll:
8802 {
8803 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8804 83 tempitem.misc3 = 0;
8805 83 tempitem.misc4 = 0;
8806 83 tempitem.misc5 = 0;
8807 83 tempitem.misc6 = 0;
8808 83 tempitem.misc7 = 0;
8809 83 tempitem.misc8 = 0;
8810 83 tempitem.misc9 = 0;
8811 83 tempitem.misc10 = 0;
8812 83 tempitem.wpn = 0;
8813 83 tempitem.wpn2 = 0;
8814 83 tempitem.wpn3 = 0;
8815 83 tempitem.wpn4 = 0;
8816 83 tempitem.wpn5 = 0;
8817 83 tempitem.wpn6 = 0;
8818 83 tempitem.wpn7 = 0;
8819 83 tempitem.wpn8 = 0;
8820 83 tempitem.wpn9 = 0;
8821 83 tempitem.wpn10 = 0;
8822 83 break;
8823 }
8824 case itype_whispring:
8825 {
8826 167 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8827 167 tempitem.misc2 = 0;
8828 167 tempitem.misc3 = 0;
8829 167 tempitem.misc4 = 0;
8830 167 tempitem.misc5 = 0;
8831 167 tempitem.misc6 = 0;
8832 167 tempitem.misc7 = 0;
8833 167 tempitem.misc8 = 0;
8834 167 tempitem.misc9 = 0;
8835 167 tempitem.misc10 = 0;
8836 167 tempitem.wpn = 0;
8837 167 tempitem.wpn2 = 0;
8838 167 tempitem.wpn3 = 0;
8839 167 tempitem.wpn4 = 0;
8840 167 tempitem.wpn5 = 0;
8841 167 tempitem.wpn6 = 0;
8842 167 tempitem.wpn7 = 0;
8843 167 tempitem.wpn8 = 0;
8844 167 tempitem.wpn9 = 0;
8845 167 tempitem.wpn10 = 0;
8846 167 break;
8847 }
8848 case itype_chargering:
8849 {
8850 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8851 166 tempitem.misc3 = 0;
8852 166 tempitem.misc4 = 0;
8853 166 tempitem.misc5 = 0;
8854 166 tempitem.misc6 = 0;
8855 166 tempitem.misc7 = 0;
8856 166 tempitem.misc8 = 0;
8857 166 tempitem.misc9 = 0;
8858 166 tempitem.misc10 = 0;
8859 166 tempitem.wpn = 0;
8860 166 tempitem.wpn2 = 0;
8861 166 tempitem.wpn3 = 0;
8862 166 tempitem.wpn4 = 0;
8863 166 tempitem.wpn5 = 0;
8864 166 tempitem.wpn6 = 0;
8865 166 tempitem.wpn7 = 0;
8866 166 tempitem.wpn8 = 0;
8867 166 tempitem.wpn9 = 0;
8868 166 tempitem.wpn10 = 0;
8869 166 break;
8870 }
8871 case itype_perilscroll:
8872 {
8873 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8874 83 tempitem.misc2 = 0;
8875 83 tempitem.misc3 = 0;
8876 83 tempitem.misc4 = 0;
8877 83 tempitem.misc5 = 0;
8878 83 tempitem.misc6 = 0;
8879 83 tempitem.misc7 = 0;
8880 83 tempitem.misc8 = 0;
8881 83 tempitem.misc9 = 0;
8882 83 tempitem.misc10 = 0;
8883 83 tempitem.wpn = 0;
8884 83 tempitem.wpn2 = 0;
8885 83 tempitem.wpn3 = 0;
8886 83 tempitem.wpn4 = 0;
8887 83 tempitem.wpn5 = 0;
8888 83 tempitem.wpn6 = 0;
8889 83 tempitem.wpn7 = 0;
8890 83 tempitem.wpn8 = 0;
8891 83 tempitem.wpn9 = 0;
8892 83 tempitem.wpn10 = 0;
8893 83 break;
8894 }
8895 case itype_wealthmedal:
8896 {
8897 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8898 250 tempitem.misc2 = 0;
8899 250 tempitem.misc3 = 0;
8900 250 tempitem.misc4 = 0;
8901 250 tempitem.misc5 = 0;
8902 250 tempitem.misc6 = 0;
8903 250 tempitem.misc7 = 0;
8904 250 tempitem.misc8 = 0;
8905 250 tempitem.misc9 = 0;
8906 250 tempitem.misc10 = 0;
8907 250 tempitem.wpn = 0;
8908 250 tempitem.wpn2 = 0;
8909 250 tempitem.wpn3 = 0;
8910 250 tempitem.wpn4 = 0;
8911 250 tempitem.wpn5 = 0;
8912 250 tempitem.wpn6 = 0;
8913 250 tempitem.wpn7 = 0;
8914 250 tempitem.wpn8 = 0;
8915 250 tempitem.wpn9 = 0;
8916 250 tempitem.wpn10 = 0;
8917 250 break;
8918 }
8919 case itype_heartring:
8920 {
8921 251 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8922 251 tempitem.misc3 = 0;
8923 251 tempitem.misc4 = 0;
8924 251 tempitem.misc5 = 0;
8925 251 tempitem.misc6 = 0;
8926 251 tempitem.misc7 = 0;
8927 251 tempitem.misc8 = 0;
8928 251 tempitem.misc9 = 0;
8929 251 tempitem.misc10 = 0;
8930 251 tempitem.wpn = 0;
8931 251 tempitem.wpn2 = 0;
8932 251 tempitem.wpn3 = 0;
8933 251 tempitem.wpn4 = 0;
8934 251 tempitem.wpn5 = 0;
8935 251 tempitem.wpn6 = 0;
8936 251 tempitem.wpn7 = 0;
8937 251 tempitem.wpn8 = 0;
8938 251 tempitem.wpn9 = 0;
8939 251 tempitem.wpn10 = 0;
8940 251 break;
8941 }
8942 case itype_magicring:
8943 {
8944 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8945 336 tempitem.misc3 = 0;
8946 336 tempitem.misc4 = 0;
8947 336 tempitem.misc5 = 0;
8948 336 tempitem.misc6 = 0;
8949 336 tempitem.misc7 = 0;
8950 336 tempitem.misc8 = 0;
8951 336 tempitem.misc9 = 0;
8952 336 tempitem.misc10 = 0;
8953 336 tempitem.wpn = 0;
8954 336 tempitem.wpn2 = 0;
8955 336 tempitem.wpn3 = 0;
8956 336 tempitem.wpn4 = 0;
8957 336 tempitem.wpn5 = 0;
8958 336 tempitem.wpn6 = 0;
8959 336 tempitem.wpn7 = 0;
8960 336 tempitem.wpn8 = 0;
8961 336 tempitem.wpn9 = 0;
8962 336 tempitem.wpn10 = 0;
8963 336 break;
8964 }
8965 case itype_spinscroll2:
8966 {
8967 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8968 83 tempitem.misc2 = 0;
8969 83 tempitem.misc3 = 0;
8970 83 tempitem.misc4 = 0;
8971 83 tempitem.misc5 = 0;
8972 83 tempitem.misc6 = 0;
8973 83 tempitem.misc7 = 0;
8974 83 tempitem.misc8 = 0;
8975 83 tempitem.misc9 = 0;
8976 83 tempitem.misc10 = 0;
8977 83 tempitem.wpn = 0;
8978 83 tempitem.wpn2 = 0;
8979 83 tempitem.wpn3 = 0;
8980 83 tempitem.wpn4 = 0;
8981 83 tempitem.wpn5 = 0;
8982 83 tempitem.wpn6 = 0;
8983 83 tempitem.wpn7 = 0;
8984 83 tempitem.wpn8 = 0;
8985 83 tempitem.wpn9 = 0;
8986 83 tempitem.wpn10 = 0;
8987 83 break;
8988 }
8989 case itype_quakescroll2:
8990 {
8991 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8992 83 tempitem.misc3 = 0;
8993 83 tempitem.misc4 = 0;
8994 83 tempitem.misc5 = 0;
8995 83 tempitem.misc6 = 0;
8996 83 tempitem.misc7 = 0;
8997 83 tempitem.misc8 = 0;
8998 83 tempitem.misc9 = 0;
8999 83 tempitem.misc10 = 0;
9000 83 tempitem.wpn = 0;
9001 83 tempitem.wpn2 = 0;
9002 83 tempitem.wpn3 = 0;
9003 83 tempitem.wpn4 = 0;
9004 83 tempitem.wpn5 = 0;
9005 83 tempitem.wpn6 = 0;
9006 83 tempitem.wpn7 = 0;
9007 83 tempitem.wpn8 = 0;
9008 83 tempitem.wpn9 = 0;
9009 83 tempitem.wpn10 = 0;
9010 83 break;
9011 }
9012 case itype_agony:
9013 {
9014 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9015 83 tempitem.misc2 = 0;
9016 83 tempitem.misc3 = 0;
9017 83 tempitem.misc4 = 0;
9018 83 tempitem.misc5 = 0;
9019 83 tempitem.misc6 = 0;
9020 83 tempitem.misc7 = 0;
9021 83 tempitem.misc8 = 0;
9022 83 tempitem.misc9 = 0;
9023 83 tempitem.misc10 = 0;
9024 83 tempitem.wpn = 0;
9025 83 tempitem.wpn2 = 0;
9026 83 tempitem.wpn3 = 0;
9027 83 tempitem.wpn4 = 0;
9028 83 tempitem.wpn5 = 0;
9029 83 tempitem.wpn6 = 0;
9030 83 tempitem.wpn7 = 0;
9031 83 tempitem.wpn8 = 0;
9032 83 tempitem.wpn9 = 0;
9033 83 tempitem.wpn10 = 0;
9034 83 break;
9035 }
9036 case itype_stompboots:
9037 {
9038 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9039 83 tempitem.misc1 = 0;
9040 83 tempitem.misc2 = 0;
9041 83 tempitem.misc3 = 0;
9042 83 tempitem.misc4 = 0;
9043 83 tempitem.misc5 = 0;
9044 83 tempitem.misc6 = 0;
9045 83 tempitem.misc7 = 0;
9046 83 tempitem.misc8 = 0;
9047 83 tempitem.misc9 = 0;
9048 83 tempitem.misc10 = 0;
9049 83 tempitem.wpn = 0;
9050 83 tempitem.wpn2 = 0;
9051 83 tempitem.wpn3 = 0;
9052 83 tempitem.wpn4 = 0;
9053 83 tempitem.wpn5 = 0;
9054 83 tempitem.wpn6 = 0;
9055 83 tempitem.wpn7 = 0;
9056 83 tempitem.wpn8 = 0;
9057 83 tempitem.wpn9 = 0;
9058 83 tempitem.wpn10 = 0;
9059 83 break;
9060 }
9061 case itype_whimsicalring:
9062 {
9063 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9064 83 tempitem.misc2 = 0;
9065 83 tempitem.misc3 = 0;
9066 83 tempitem.misc4 = 0;
9067 83 tempitem.misc5 = 0;
9068 83 tempitem.misc6 = 0;
9069 83 tempitem.misc7 = 0;
9070 83 tempitem.misc8 = 0;
9071 83 tempitem.misc9 = 0;
9072 83 tempitem.misc10 = 0;
9073 83 tempitem.wpn = 0;
9074 83 tempitem.wpn2 = 0;
9075 83 tempitem.wpn3 = 0;
9076 83 tempitem.wpn4 = 0;
9077 83 tempitem.wpn5 = 0;
9078 83 tempitem.wpn6 = 0;
9079 83 tempitem.wpn7 = 0;
9080 83 tempitem.wpn8 = 0;
9081 83 tempitem.wpn9 = 0;
9082 83 tempitem.wpn10 = 0;
9083 83 break;
9084 }
9085 case itype_perilring:
9086 {
9087 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9088 84 tempitem.misc2 = 0;
9089 84 tempitem.misc3 = 0;
9090 84 tempitem.misc4 = 0;
9091 84 tempitem.misc5 = 0;
9092 84 tempitem.misc6 = 0;
9093 84 tempitem.misc7 = 0;
9094 84 tempitem.misc8 = 0;
9095 84 tempitem.misc9 = 0;
9096 84 tempitem.misc10 = 0;
9097 84 tempitem.wpn = 0;
9098 84 tempitem.wpn2 = 0;
9099 84 tempitem.wpn3 = 0;
9100 84 tempitem.wpn4 = 0;
9101 84 tempitem.wpn5 = 0;
9102 84 tempitem.wpn6 = 0;
9103 84 tempitem.wpn7 = 0;
9104 84 tempitem.wpn8 = 0;
9105 84 tempitem.wpn9 = 0;
9106 84 tempitem.wpn10 = 0;
9107 84 break;
9108 }
9109 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9110 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9111 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9112 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9113 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9114 {
9115 2230 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9116 2230 tempitem.misc1 = 0;
9117 2230 tempitem.misc2 = 0;
9118 2230 tempitem.misc3 = 0;
9119 2230 tempitem.misc4 = 0;
9120 2230 tempitem.misc5 = 0;
9121 2230 tempitem.misc6 = 0;
9122 2230 tempitem.misc7 = 0;
9123 2230 tempitem.misc8 = 0;
9124 2230 tempitem.misc9 = 0;
9125 2230 tempitem.misc10 = 0;
9126 2230 tempitem.wpn = 0;
9127 2230 tempitem.wpn2 = 0;
9128 2230 tempitem.wpn3 = 0;
9129 2230 tempitem.wpn4 = 0;
9130 2230 tempitem.wpn5 = 0;
9131 2230 tempitem.wpn6 = 0;
9132 2230 tempitem.wpn7 = 0;
9133 2230 tempitem.wpn8 = 0;
9134 2230 tempitem.wpn9 = 0;
9135 2230 tempitem.wpn10 = 0;
9136 2230 break;
9137 }
9138 }
9139 21504 }
9140 //Port quest rules to items
9141
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version <= 31)
9142 {
9143
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 21406 times.
21504 if(tempitem.family == itype_bomb)
9144 {
9145
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 10 times.
98 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9146 88 else tempitem.flags &= ~ ITEM_FLAG2;
9147 98 }
9148
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21323 times.
21406 else if(tempitem.family == itype_sbomb)
9149 {
9150
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 73 times.
83 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9151 73 else tempitem.flags &= ~ ITEM_FLAG2;
9152 83 }
9153
9154
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 21073 times.
21323 else if(tempitem.family == itype_brang)
9155 {
9156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9157 250 else tempitem.flags &= ~ ITEM_FLAG4;
9158 250 }
9159
2/2
✓ Branch 0 taken 20975 times.
✓ Branch 1 taken 98 times.
21073 else if(tempitem.family == itype_wand)
9160 {
9161
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 96 times.
98 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9162 96 else tempitem.flags &= ~ ITEM_FLAG3;
9163 98 }
9164 21504 }
9165
9166 //Port quest rules to items
9167
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version <= 37)
9168 {
9169
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21420 times.
21504 if(tempitem.family == itype_flippers)
9170 {
9171
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9172 84 else tempitem.flags &= ~ ITEM_FLAG1;
9173 84 }
9174
2/2
✓ Branch 0 taken 14576 times.
✓ Branch 1 taken 6844 times.
21420 else if(tempitem.family == itype_sword)
9175 {
9176
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6775 times.
6844 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9177 6775 else tempitem.flags &= ~ ITEM_FLAG5;
9178 6844 }
9179
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 14478 times.
14576 else if(tempitem.family == itype_wand)
9180 {
9181
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 95 times.
98 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9182 95 else tempitem.flags &= ~ ITEM_FLAG5;
9183 98 }
9184
4/4
✓ Branch 0 taken 14380 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 14176 times.
14478 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9185 {
9186 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9187
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 72 times.
302 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9188 230 else tempitem.flags &= ~ ITEM_FLAG3;
9189 302 }
9190 21504 }
9191
9192
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 38)
9193 {
9194
4/4
✓ Branch 0 taken 21254 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 21088 times.
21504 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9195 {
9196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9197 416 else tempitem.flags &= ~ITEM_FLAG4;
9198
9199
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 405 times.
416 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9200 405 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9201 416 }
9202
2/2
✓ Branch 0 taken 20841 times.
✓ Branch 1 taken 247 times.
21088 else if(tempitem.family == itype_arrow)
9203 {
9204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247 times.
247 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9205 247 else tempitem.flags &= ~ITEM_FLAG4;
9206
9207
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 243 times.
247 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9208 243 else tempitem.flags |= ITEM_FLAG2;
9209 247 }
9210 21504 }
9211
9212
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 39)
9213 {
9214
6/6
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 21323 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 21119 times.
21504 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9215 {
9216
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 373 times.
385 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9217 373 else tempitem.flags &= ~ITEM_FLAG5;
9218 385 }
9219
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 20954 times.
21119 else if(tempitem.family == itype_potion)
9220 {
9221
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 155 times.
165 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9222 {
9223 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9224 10 }
9225 else
9226 {
9227 155 tempitem.flags |= ITEM_FLAG3;
9228
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 85 times.
155 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9229 70 else tempitem.flags &= ~ITEM_FLAG4;
9230 }
9231 165 }
9232
2/2
✓ Branch 0 taken 20788 times.
✓ Branch 1 taken 166 times.
20954 else if(tempitem.family == itype_triforcepiece)
9233 {
9234
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 150 times.
166 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9235 {
9236 16 tempitem.flags |= ITEM_FLAG3;
9237
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9238 10 else tempitem.flags &= ~ITEM_FLAG4;
9239 16 }
9240 else
9241 {
9242 150 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9243 }
9244 166 }
9245 21504 }
9246
9247
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 40)
9248 {
9249
4/4
✓ Branch 0 taken 21229 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 21145 times.
21504 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9250 {
9251
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 312 times.
359 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9252 312 else tempitem.flags &= ~ITEM_FLAG1;
9253 359 }
9254
8/8
✓ Branch 0 taken 20941 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 14097 times.
✓ Branch 3 taken 6844 times.
✓ Branch 4 taken 13999 times.
✓ Branch 5 taken 98 times.
✓ Branch 6 taken 83 times.
✓ Branch 7 taken 13916 times.
21145 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9255 {
9256
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7148 times.
7229 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9257 7148 else tempitem.flags &= ~ITEM_FLAG8;
9258 7229 }
9259
6/6
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 6844 times.
✓ Branch 2 taken 14562 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 14478 times.
21504 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9260 {
9261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7026 times.
7026 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9262 7026 else tempitem.flags &= ~ITEM_FLAG7;
9263 7026 }
9264
2/2
✓ Branch 0 taken 14395 times.
✓ Branch 1 taken 83 times.
14478 else if(tempitem.family == itype_cbyrna)
9265 {
9266 83 tempitem.flags |= ITEM_FLAG7;
9267 83 }
9268 21504 }
9269
9270
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 41 )
9271 {
9272
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 6844 times.
21504 if(tempitem.family == itype_sword)
9273 {
9274
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6775 times.
6844 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9275 6775 else tempitem.flags &= ~ITEM_FLAG9;
9276
9277
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6775 times.
6844 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9278 6775 else tempitem.flags &= ~ITEM_FLAG10;
9279 6844 }
9280 21504 }
9281
9282
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 42 )
9283 {
9284
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 21406 times.
21504 if(tempitem.family == itype_wand)
9285 {
9286
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 2 times.
98 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9287 96 else tempitem.flags &= ~ITEM_FLAG3;
9288
9289 98 tempitem.flags &= ~ITEM_FLAG6;
9290 98 }
9291
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21322 times.
21406 else if(tempitem.family == itype_hammer)
9292 {
9293 84 tempitem.flags &= ~ITEM_FLAG3;
9294 84 }
9295
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21239 times.
21322 else if(tempitem.family == itype_cbyrna)
9296 {
9297 83 tempitem.flags |= ITEM_FLAG3;
9298
9299 83 tempitem.flags &= ~ITEM_FLAG6;
9300 83 }
9301
2/2
✓ Branch 0 taken 14395 times.
✓ Branch 1 taken 6844 times.
21239 else if(tempitem.family == itype_sword)
9302 {
9303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6844 times.
6844 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9304 6844 else tempitem.flags &= ~ITEM_FLAG6;
9305 6844 }
9306 21504 }
9307
9308
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 43 )
9309 {
9310
2/2
✓ Branch 0 taken 21375 times.
✓ Branch 1 taken 129 times.
21504 if(tempitem.family == itype_whistle)
9311 {
9312
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9313 126 else tempitem.flags &= ~ITEM_FLAG3;
9314 129 }
9315 21504 }
9316
9317
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 45 )
9318 {
9319
2/2
✓ Branch 0 taken 21420 times.
✓ Branch 1 taken 84 times.
21504 if(tempitem.family == itype_flippers)
9320 {
9321 84 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9322 84 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9323 84 }
9324 21504 }
9325
9326
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 46 )
9327 {
9328
2/2
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
21504 if(tempitem.family == itype_raft)
9329 {
9330 83 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9331 83 }
9332 21504 }
9333
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if ( s_version < 34 ) //! set the default counter for older quests.
9334 {
9335
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 21431 times.
21504 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9336 {
9337 73 tempitem.cost_counter[0] = 1;
9338 73 }
9339 else
9340 {
9341
2/2
✓ Branch 0 taken 18615 times.
✓ Branch 1 taken 2816 times.
21431 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9342 2816 tempitem.cost_counter[0] = 4;
9343 else
9344 {
9345 18615 tempitem.cost_amount[0] = 0;
9346 18615 tempitem.cost_counter[0] = -1;
9347 }
9348 }
9349 21504 }
9350
9351
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if ( s_version < 35 ) //new Lens of Truth flags
9352 {
9353
2/2
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
21504 if ( tempitem.family == itype_lens )
9354 {
9355
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
83 if ( get_bit(quest_rules,qr_RAFTLENS) )
9356 {
9357 3 tempitem.flags |= ITEM_FLAG4;
9358 3 }
9359
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 45 times.
83 if ( get_bit(quest_rules,qr_LENSHINTS) )
9360 {
9361 45 tempitem.flags |= ITEM_FLAG1;
9362 45 }
9363
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 4 times.
83 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9364 {
9365 4 tempitem.flags |= ITEM_FLAG5;
9366 4 }
9367 83 }
9368 21504 }
9369
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9370 {
9371
2/2
✓ Branch 0 taken 172032 times.
✓ Branch 1 taken 21504 times.
193536 for ( int32_t q = 0; q < 8; q++ )
9372 {
9373 172032 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9374 172032 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9375 172032 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9376 172032 tempitem.sprite_initiald[q] = 0;
9377 172032 }
9378
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 21504 times.
64512 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9379 21504 tempitem.sprite_script = 0;
9380 21504 }
9381
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9382 {
9383 21504 tempitem.pickupflag = 0;
9384 21504 }
9385
9386
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 51 )
9387 {
9388
2/2
✓ Branch 0 taken 21300 times.
✓ Branch 1 taken 204 times.
21504 if( tempitem.family == itype_candle )
9389 {
9390 204 tempitem.misc4 = 50; //Step speed
9391 204 }
9392 21504 }
9393
9394
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if( s_version < 52 )
9395 {
9396
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 256 times.
21504 if( tempitem.family == itype_shield )
9397 256 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9398 21504 }
9399
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 21504 times.
27648 if(s_version < 53)
9400 {
9401
4/4
✓ Branch 0 taken 21076 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 83 times.
21504 switch(tempitem.family)
9402 {
9403 case itype_arrow:
9404 247 tempitem.cost_counter[1] = crARROWS;
9405 247 tempitem.cost_amount[1] = 1;
9406 247 break;
9407 case itype_bomb:
9408 98 tempitem.cost_counter[1] = crBOMBS;
9409 98 tempitem.cost_amount[1] = 1;
9410 98 break;
9411 case itype_sbomb:
9412 83 tempitem.cost_counter[1] = crSBOMBS;
9413 83 tempitem.cost_amount[1] = 1;
9414 83 break;
9415 default:
9416 21076 tempitem.cost_counter[1] = crNONE;
9417 21076 tempitem.cost_amount[1] = 0;
9418 21076 }
9419 21504 tempitem.magiccosttimer[1] = 0;
9420 21504 }
9421
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if( s_version < 54 )
9422 {
9423
2/2
✓ Branch 0 taken 25244 times.
✓ Branch 1 taken 100 times.
25344 if( tempitem.family == itype_flippers )
9424 100 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9425 25344 }
9426
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if(s_version < 55)
9427 {
9428
3/3
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 24952 times.
25344 switch(tempitem.family)
9429 {
9430 case itype_spinscroll:
9431 case itype_quakescroll:
9432 196 tempitem.usesound2 = WAV_ZN1CHARGE;
9433 196 break;
9434 case itype_spinscroll2:
9435 case itype_quakescroll2:
9436 196 tempitem.usesound2 = WAV_ZN1CHARGE2;
9437 196 break;
9438 }
9439 25344 }
9440
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25344 times.
27648 if(s_version < 56)
9441 {
9442
4/4
✓ Branch 0 taken 24897 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 113 times.
25344 switch(tempitem.family)
9443 {
9444 case itype_divinefire:
9445
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 15 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9446
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9447 98 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9448 98 break;
9449 case itype_candle:
9450
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 121 times.
236 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9451 236 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9452 236 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9453 236 break;
9454 case itype_book:
9455 113 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9456 113 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9457 113 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9458 113 break;
9459 }
9460 25344 }
9461
9462
2/2
✓ Branch 0 taken 26442 times.
✓ Branch 1 taken 1206 times.
27648 if(tempitem.fam_type==0) // Always do this
9463 1206 tempitem.fam_type=1;
9464
9465 27648 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9466 27648 }
9467 108 }
9468
9469 108 return 0;
9470 108 }
9471
9472 static bool did_init_def_items = false;
9473 56055 void init_def_items()
9474 {
9475
2/2
✓ Branch 0 taken 56022 times.
✓ Branch 1 taken 33 times.
56055 if(did_init_def_items) return;
9476 33 did_init_def_items = true;
9477 33 default_items[3].cost_counter[1] = crBOMBS;
9478 33 default_items[13].cost_counter[1] = crARROWS;
9479 33 default_items[14].cost_counter[1] = crARROWS;
9480 33 default_items[48].cost_counter[1] = crSBOMBS;
9481 33 default_items[57].cost_counter[1] = crARROWS;
9482 56055 }
9483 56055 void reset_itembuf(itemdata *item, int32_t id)
9484 {
9485 56055 init_def_items();
9486
2/2
✓ Branch 0 taken 24295 times.
✓ Branch 1 taken 31760 times.
56055 if(id<iLast)
9487 {
9488 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9489 31760 word tile = item->tile;
9490 31760 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9491 31760 int32_t ltm = item->ltm;
9492
9493 31760 memcpy(item,&default_items[id],sizeof(itemdata));
9494 31760 item->tile = tile;
9495 31760 item->misc_flags = miscs;
9496 31760 item->csets = cset;
9497 31760 item->frames = frames;
9498 31760 item->speed = speed;
9499 31760 item->delay = delay;
9500 31760 item->ltm = ltm;
9501 31760 }
9502 56055 }
9503
9504 10752 void reset_itemname(int32_t id)
9505 {
9506 10752 sprintf(item_string[id],"zz%03d",id);
9507
9508
2/2
✓ Branch 0 taken 4746 times.
✓ Branch 1 taken 6006 times.
10752 if(id < iLast)
9509 6006 strcpy(item_string[id],old_item_string[id]);
9510 10752 }
9511
9512 108 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9513 {
9514 108 word weapons_to_read=MAXWPNS;
9515 int32_t dummy;
9516 byte padding;
9517 wpndata tempweapon;
9518 108 word s_version=0, s_cversion=0;
9519
9520
9521
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x186)
9522 {
9523 weapons_to_read=64;
9524 }
9525
9526
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x185)
9527 {
9528 weapons_to_read=32;
9529 }
9530
9531
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
9532 {
9533 104 weapons_to_read=0;
9534
9535 //section version info
9536
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
9537 {
9538 return qe_invalid;
9539 }
9540
9541 104 FFCore.quest_format[vWeaponSprites] = s_version;
9542
9543 //al_trace("Weapons version %d\n", s_version);
9544
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_cversion,f,true))
9545 {
9546 return qe_invalid;
9547 }
9548
9549 //section size
9550
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
9551 {
9552 return qe_invalid;
9553 }
9554
9555 //finally... section data
9556
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&weapons_to_read,f,true))
9557 {
9558 return qe_invalid;
9559 }
9560 104 }
9561
9562
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version>2)
9563 {
9564
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<weapons_to_read; i++)
9565 {
9566 char tempname[64];
9567
9568
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(!pfread(tempname, 64, f, keepdata))
9569 {
9570 return qe_invalid;
9571 }
9572
9573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
25344 if(keepdata)
9574 {
9575 25344 strcpy(weapon_string[i], tempname);
9576 25344 }
9577 25344 }
9578
9579
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version<4)
9580 {
9581 if(keepdata)
9582 {
9583 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9584 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9585 }
9586 }
9587
9588
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version<5)
9589 {
9590 if(keepdata)
9591 {
9592 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9593 }
9594 }
9595
9596 /*
9597 if (s_version<6)
9598 {
9599 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9600 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9601 }
9602 */
9603 99 }
9604 else
9605 {
9606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9607
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9608 2313 reset_weaponname(i);
9609 }
9610
9611
2/2
✓ Branch 0 taken 26708 times.
✓ Branch 1 taken 108 times.
26816 for(int32_t i=0; i<weapons_to_read; i++)
9612 {
9613 26708 word oldtile = 0;
9614
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 21076 times.
26708 if (s_version < 8)
9615 {
9616
1/2
✓ Branch 0 taken 21076 times.
✗ Branch 1 not taken.
21076 if (!p_igetw(&oldtile, f, true))
9617 return qe_invalid;
9618 21076 }
9619
9620
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.misc,f,true))
9621 {
9622 return qe_invalid;
9623 }
9624
9625
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.csets,f,true))
9626 {
9627 return qe_invalid;
9628 }
9629
9630
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.frames,f,true))
9631 {
9632 return qe_invalid;
9633 }
9634
9635
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.speed,f,true))
9636 {
9637 return qe_invalid;
9638 }
9639
9640
1/2
✓ Branch 0 taken 26708 times.
✗ Branch 1 not taken.
26708 if(!p_getc(&tempweapon.type,f,true))
9641 {
9642 return qe_invalid;
9643 }
9644
9645
2/2
✓ Branch 0 taken 20564 times.
✓ Branch 1 taken 6144 times.
26708 if ( s_version >= 7 )
9646 {
9647
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetw(&tempweapon.script,f,true))
9648 {
9649 return qe_invalid;
9650 }
9651
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(!p_igetl(&tempweapon.tile,f,true))
9652 {
9653 return qe_invalid;
9654 }
9655 6144 }
9656
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 20564 times.
26708 if ( s_version < 7 )
9657 {
9658 20564 tempweapon.tile = oldtile;
9659 20564 }
9660
9661
2/2
✓ Branch 0 taken 25684 times.
✓ Branch 1 taken 1024 times.
26708 if(Header->zelda_version < 0x193)
9662 {
9663
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9664 {
9665 return qe_invalid;
9666 }
9667 1024 }
9668
9669
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 1364 times.
26708 if(s_version < 6)
9670 {
9671
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9672 {
9673 4 tempweapon.misc |= WF_BEHIND;
9674 4 }
9675 else
9676 1360 tempweapon.misc &= ~WF_BEHIND;
9677 1364 }
9678
9679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26708 times.
26708 if(keepdata==true)
9680 {
9681 26708 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9682 26708 }
9683 26708 }
9684
9685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
9686 {
9687
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<2)
9688 {
9689 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9690 9 }
9691
9692
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version<5)
9693 {
9694 9 wpnsbuf[iwQuarterHearts].tile=1;
9695 9 wpnsbuf[iwQuarterHearts].csets=1;
9696 9 }
9697
9698
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x176)
9699 {
9700 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9701 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9702 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9703 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9704 }
9705
9706
2/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108 if((Header->zelda_version < 0x192)||
9707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9708 {
9709 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9710 4 }
9711
9712
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if((Header->zelda_version < 0x210))
9713 {
9714 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9715 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9716 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9717 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9718 4 }
9719 108 }
9720
9721 108 return 0;
9722 108 }
9723
9724 108 void init_guys(int32_t guyversion)
9725 {
9726
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<MAXGUYS; i++)
9727 {
9728 55296 guysbuf[i] = default_guys[0];
9729 55296 }
9730
9731
2/2
✓ Branch 0 taken 19116 times.
✓ Branch 1 taken 108 times.
19224 for(int32_t i=0; i<OLDMAXGUYS; i++)
9732 {
9733 19116 guysbuf[i] = default_guys[i];
9734
2/2
✓ Branch 0 taken 18900 times.
✓ Branch 1 taken 216 times.
19116 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9735 19116 guysbuf[i].spr_death = iwDeath;
9736 19116 guysbuf[i].spr_spawn = iwSpawn;
9737 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9738
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 17523 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
19116 if(guyversion<=3 && i==ePATRABS)
9739 {
9740 9 guysbuf[i].bosspal=spDIG;
9741 9 guysbuf[i].cset=14;
9742 9 guysbuf[i].misc9=14;
9743 9 }
9744
9745
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 1593 times.
19116 if(guyversion<=3)
9746 {
9747 // Rope/Ghini Flash rules
9748
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9749 {
9750
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9751 {
9752 5 guysbuf[i].flags2 &= ~guy_flashing;
9753 5 }
9754 885 }
9755
9756
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9757 {
9758
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9759 {
9760 18 guysbuf[i].flags2 &= ~guy_flashing;
9761 18 }
9762 531 }
9763
9764
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9765 {
9766
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9767 {
9768 3 guysbuf[i].flags2 |= guy_blinking;
9769 3 }
9770
9771
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9772 {
9773 guysbuf[i].flags2 |= guy_transparent;
9774 }
9775 9 }
9776 1593 }
9777
9778 // Darknut fix
9779
10/10
✓ Branch 0 taken 19008 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 18900 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 18792 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 18684 times.
✓ Branch 7 taken 108 times.
✓ Branch 8 taken 108 times.
✓ Branch 9 taken 18576 times.
19116 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9780 {
9781
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 200 times.
540 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9782 {
9783 340 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9784 340 guysbuf[i].s_width=guysbuf[i].e_width;
9785 340 guysbuf[i].s_height=guysbuf[i].e_height;
9786 340 }
9787 200 else guysbuf[i].s_tile=860;
9788
9789
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 35 times.
540 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9790 {
9791 35 guysbuf[i].flags |= guy_bkshield;
9792 35 }
9793 540 }
9794
9795
4/4
✓ Branch 0 taken 19008 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 19108 times.
✓ Branch 3 taken 8 times.
19116 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9796 {
9797 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9798 8 }
9799 19116 }
9800 108 }
9801
9802 2304 void reset_weaponname(int32_t i)
9803 {
9804
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9805 {
9806 792 strcpy(weapon_string[i],old_weapon_string[i]);
9807 792 }
9808 else
9809 1512 sprintf(weapon_string[i],"zz%03d",i);
9810 2304 }
9811
9812 108 void init_item_drop_sets()
9813 {
9814
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9815 {
9816 // item_drop_sets[i] = default_item_drop_sets[0];
9817 27648 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9818 27648 }
9819
9820
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 108 times.
1512 for(int32_t i=0; i<isMAX; i++)
9821 {
9822 1404 item_drop_sets[i] = default_item_drop_sets[i];
9823
9824 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9825
2/2
✓ Branch 0 taken 14040 times.
✓ Branch 1 taken 1404 times.
15444 for(int32_t j=0; j<10; ++j)
9826 {
9827 14040 int32_t it = item_drop_sets[i].item[j];
9828
9829
3/4
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 4196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 636 times.
14040 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9830
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 9208 times.
9844 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9831 {
9832 636 item_drop_sets[i].chance[j+1]=0;
9833 636 }
9834
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 12972 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
13404 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9835 {
9836 item_drop_sets[i].chance[j+1]=0;
9837 }
9838
9839 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9840
2/2
✓ Branch 0 taken 14032 times.
✓ Branch 1 taken 8 times.
14040 if(itemsbuf[it].family == itype_misc)
9841 {
9842 // If a non-gameplay item was selected, then item drop was aborted.
9843 // Reflect this by increasing the 'Nothing' chance accordingly.
9844 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9845 8 item_drop_sets[i].chance[j+1]=0;
9846 8 }
9847 14040 }
9848 1404 }
9849 108 }
9850
9851 104 void init_favorites()
9852 {
9853
2/2
✓ Branch 0 taken 31200 times.
✓ Branch 1 taken 104 times.
31304 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9854 {
9855 31200 favorite_combos[i]=-1;
9856 31200 }
9857
9858
2/2
✓ Branch 0 taken 31200 times.
✓ Branch 1 taken 104 times.
31304 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9859 {
9860 31200 favorite_comboaliases[i]=-1;
9861 31200 }
9862 104 }
9863
9864 const char *ctype_name[cMAX]=
9865 {
9866 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9867 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9868 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9869 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9870 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9871 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9872 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9873 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9874 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9875 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9876 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9877 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9878 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9879 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9880 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9881 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9882 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9883 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9884 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9885 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9886 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9887 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9888 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9889 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9890 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9891 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9892 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9893 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9894
9895 };
9896
9897 194 int32_t init_combo_classes()
9898 {
9899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9900
2/2
✓ Branch 0 taken 35114 times.
✓ Branch 1 taken 194 times.
35308 for(int32_t i=0; i<cMAX; i++)
9901 {
9902 35114 combo_class_buf[i] = default_combo_classes[i];
9903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35114 times.
35114 if ( char const* nm = zi->getComboTypeName(i) )
9904 {
9905 35114 size_t len = strlen(nm);
9906
2/2
✓ Branch 0 taken 2247296 times.
✓ Branch 1 taken 35114 times.
2282410 for ( size_t q = 0; q < 64; q++ )
9907 {
9908
2/2
✓ Branch 0 taken 518950 times.
✓ Branch 1 taken 1728346 times.
2247296 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9909 2247296 }
9910 35114 }
9911 35114 }
9912
9913 194 return 0;
9914 }
9915
9916 88 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9917 {
9918
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 assert(v_herosprites < 6);
9919 //these are here to bypass compiler warnings about unused arguments
9920 88 cv_herosprites=cv_herosprites;
9921
9922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
9923 {
9924 88 zinit.hero_swim_speed=67; //default
9925 88 setupherotiles(zinit.heroAnimationStyle);
9926 88 setupherodefenses();
9927 88 setupherooffsets();
9928 88 }
9929
9930
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 75 times.
88 if(v_herosprites>=0)
9931 {
9932 word tile, tile2;
9933 byte flip, extend, dummy_byte;
9934
9935
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
9936 {
9937
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
9938 {
9939 return qe_invalid;
9940 }
9941
9942
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
9943 {
9944 return qe_invalid;
9945 }
9946
9947
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
9948 {
9949 return qe_invalid;
9950 }
9951
9952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
9953 {
9954 300 walkspr[i][spr_tile]=(int32_t)tile;
9955 300 walkspr[i][spr_flip]=(int32_t)flip;
9956 300 walkspr[i][spr_extend]=(int32_t)extend;
9957 300 }
9958 300 }
9959
9960
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
9961 {
9962
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
9963 {
9964 return qe_invalid;
9965 }
9966
9967
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
9968 {
9969 return qe_invalid;
9970 }
9971
9972
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
9973 {
9974 return qe_invalid;
9975 }
9976
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
9978 {
9979 300 stabspr[i][spr_tile]=(int32_t)tile;
9980 300 stabspr[i][spr_flip]=(int32_t)flip;
9981 300 stabspr[i][spr_extend]=(int32_t)extend;
9982 300 }
9983 300 }
9984
9985
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
9986 {
9987
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
9988 {
9989 return qe_invalid;
9990 }
9991
9992
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
9993 {
9994 return qe_invalid;
9995 }
9996
9997
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
9998 {
9999 return qe_invalid;
10000 }
10001
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10003 {
10004 300 slashspr[i][spr_tile]=(int32_t)tile;
10005 300 slashspr[i][spr_flip]=(int32_t)flip;
10006 300 slashspr[i][spr_extend]=(int32_t)extend;
10007 300 }
10008 300 }
10009
10010
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10011 {
10012
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10013 {
10014 return qe_invalid;
10015 }
10016
10017
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10018 {
10019 return qe_invalid;
10020 }
10021
10022
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10023 {
10024 return qe_invalid;
10025 }
10026
10027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10028 {
10029 300 floatspr[i][spr_tile]=(int32_t)tile;
10030 300 floatspr[i][spr_flip]=(int32_t)flip;
10031 300 floatspr[i][spr_extend]=(int32_t)extend;
10032 300 }
10033 300 }
10034
10035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>1)
10036 {
10037
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10038 {
10039
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10040 {
10041 return qe_invalid;
10042 }
10043
10044
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10045 {
10046 return qe_invalid;
10047 }
10048
10049
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10050 {
10051 return qe_invalid;
10052 }
10053
10054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10055 {
10056 300 swimspr[i][spr_tile]=(int32_t)tile;
10057 300 swimspr[i][spr_flip]=(int32_t)flip;
10058 300 swimspr[i][spr_extend]=(int32_t)extend;
10059 300 }
10060 300 }
10061 75 }
10062
10063
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10064 {
10065
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10066 {
10067 return qe_invalid;
10068 }
10069
10070
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10071 {
10072 return qe_invalid;
10073 }
10074
10075
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10076 {
10077 return qe_invalid;
10078 }
10079
10080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10081 {
10082 300 divespr[i][spr_tile]=(int32_t)tile;
10083 300 divespr[i][spr_flip]=(int32_t)flip;
10084 300 divespr[i][spr_extend]=(int32_t)extend;
10085 300 }
10086 300 }
10087
10088
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10089 {
10090
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10091 {
10092 return qe_invalid;
10093 }
10094
10095
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10101 {
10102 return qe_invalid;
10103 }
10104
10105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10106 {
10107 300 poundspr[i][spr_tile]=(int32_t)tile;
10108 300 poundspr[i][spr_flip]=(int32_t)flip;
10109 300 poundspr[i][spr_extend]=(int32_t)extend;
10110 300 }
10111 300 }
10112
10113
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&tile,f,keepdata))
10114 {
10115 return qe_invalid;
10116 }
10117
10118 75 flip=0;
10119
10120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>0)
10121 {
10122
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&flip,f,keepdata))
10123 {
10124 return qe_invalid;
10125 }
10126 75 }
10127
10128
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&extend,f,keepdata))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
10134 {
10135 75 castingspr[spr_tile]=(int32_t)tile;
10136 75 castingspr[spr_flip]=(int32_t)flip;
10137 75 castingspr[spr_extend]=(int32_t)extend;
10138 75 }
10139
10140
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(v_herosprites>0)
10141 {
10142 75 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10143
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 75 times.
225 for(int32_t i=0; i<2; i++)
10144 {
10145
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 150 times.
450 for(int32_t j=0; j<num_holdsprs; j++)
10146 {
10147
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10148 {
10149 return qe_invalid;
10150 }
10151
10152
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10153 {
10154 return qe_invalid;
10155 }
10156
10157
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10158 {
10159 return qe_invalid;
10160 }
10161
10162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10163 {
10164 300 holdspr[i][j][spr_tile]=(int32_t)tile;
10165 300 holdspr[i][j][spr_flip]=(int32_t)flip;
10166 300 holdspr[i][j][spr_extend]=(int32_t)extend;
10167 300 }
10168 300 }
10169 150 }
10170 75 }
10171 else
10172 {
10173 for(int32_t i=0; i<2; i++)
10174 {
10175 if(!p_igetw(&tile,f,keepdata))
10176 {
10177 return qe_invalid;
10178 }
10179
10180 if(!p_igetw(&tile2,f,keepdata))
10181 {
10182 return qe_invalid;
10183 }
10184
10185 if(!p_getc(&extend,f,keepdata))
10186 {
10187 return qe_invalid;
10188 }
10189
10190 if(keepdata)
10191 {
10192 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10193 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10194 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10195 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10196 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10197 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10198 }
10199 }
10200 }
10201
10202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>2)
10203 {
10204
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10205 {
10206
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10212 {
10213 return qe_invalid;
10214 }
10215
10216
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10217 {
10218 return qe_invalid;
10219 }
10220
10221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10222 {
10223 300 jumpspr[i][spr_tile]=(int32_t)tile;
10224 300 jumpspr[i][spr_flip]=(int32_t)flip;
10225 300 jumpspr[i][spr_extend]=(int32_t)extend;
10226 300 }
10227 300 }
10228 75 }
10229
10230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>3)
10231 {
10232
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10233 {
10234
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10235 {
10236 return qe_invalid;
10237 }
10238
10239
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10240 {
10241 return qe_invalid;
10242 }
10243
10244
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10245 {
10246 return qe_invalid;
10247 }
10248
10249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10250 {
10251 300 chargespr[i][spr_tile]=(int32_t)tile;
10252 300 chargespr[i][spr_flip]=(int32_t)flip;
10253 300 chargespr[i][spr_extend]=(int32_t)extend;
10254 300 }
10255 300 }
10256 75 }
10257
10258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>4)
10259 {
10260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!p_getc(&dummy_byte,f,keepdata))
10261 {
10262 return qe_invalid;
10263 }
10264
10265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
10266 {
10267 75 zinit.hero_swim_speed=(byte)dummy_byte;
10268 75 }
10269 75 }
10270
10271
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(keepdata)
10272 {
10273 75 memset(frozenspr, 0, sizeof(frozenspr));
10274 75 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10275 75 memset(onfirespr, 0, sizeof(onfirespr));
10276 75 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10277 75 memset(diggingspr, 0, sizeof(diggingspr));
10278 75 memset(usingrodspr, 0, sizeof(usingrodspr));
10279 75 memset(usingcanespr, 0, sizeof(usingcanespr));
10280 75 memset(pushingspr, 0, sizeof(pushingspr));
10281 75 memset(liftingspr, 0, sizeof(liftingspr));
10282 75 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10283 75 memset(stunnedspr, 0, sizeof(stunnedspr));
10284 75 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10285 75 memset(fallingspr, 0, sizeof(fallingspr));
10286 75 memset(shockedspr, 0, sizeof(shockedspr));
10287 75 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10288 75 memset(pullswordspr, 0, sizeof(pullswordspr));
10289 75 memset(readingspr, 0, sizeof(readingspr));
10290 75 memset(slash180spr, 0, sizeof(slash180spr));
10291 75 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10292 75 memset(dashspr, 0, sizeof(dashspr));
10293 75 memset(bonkspr, 0, sizeof(bonkspr));
10294 75 memset(medallionsprs, 0, sizeof(medallionsprs));
10295 75 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10296 75 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10297
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t q = 0; q < 4; ++q)
10298 {
10299
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 300 times.
1200 for(int32_t p = 0; p < 3; ++p)
10300 {
10301 900 drowningspr[q][p] = divespr[q][p];
10302 900 drowning_lavaspr[q][p] = divespr[q][p];
10303 900 }
10304 300 }
10305 75 memset(sideswimspr, 0, sizeof(sideswimspr));
10306 75 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10307 75 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10308 75 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10309 75 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10310 75 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10311 75 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10312 75 }
10313 75 }
10314
10315
2/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
88 if(keepdata && FFCore.quest_format[vInitData] < 34)
10316 {
10317 88 bool fastswim = zinit.hero_swim_speed > 60;
10318 // '2/3' or '1/2'
10319 88 zinit.hero_swim_mult = fastswim ? 2 : 1;
10320 88 zinit.hero_swim_div = fastswim ? 3 : 2;
10321 88 }
10322 88 return 0;
10323 88 }
10324
10325 4080 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10326 {
10327 4080 arr[spr_tile] = tile;
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
4080 arr[spr_flip] = (flip > 3 ? 0 : flip);
10329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
4080 arr[spr_extend] = (ext > 2 ? 0 : ext);
10330 4080 }
10331 //Used to read the player sprites as int32_t, not word.
10332 24 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10333 {
10334 //these are here to bypass compiler warnings about unused arguments
10335 24 cv_herosprites=cv_herosprites;
10336
10337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
10338 {
10339 24 zinit.hero_swim_speed=67; //default
10340 24 setupherotiles(zinit.heroAnimationStyle);
10341 24 setupherodefenses();
10342 24 setupherooffsets();
10343 24 }
10344
10345 int32_t tile, tile2;
10346 byte flip, extend, dummy_byte;
10347
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>=0)
10349 {
10350
10351
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10352 {
10353
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10354 {
10355 return qe_invalid;
10356 }
10357
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10364 {
10365 return qe_invalid;
10366 }
10367
10368 96 if(keepdata)
10369 {
10370 96 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10371 96 }
10372 96 }
10373
10374
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10375 {
10376
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10377 {
10378 return qe_invalid;
10379 }
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10392 {
10393 96 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10394 96 }
10395 96 }
10396
10397
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10410 {
10411 return qe_invalid;
10412 }
10413
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10415 {
10416 96 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 96 }
10418 96 }
10419
10420
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10421 {
10422
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10423 {
10424 return qe_invalid;
10425 }
10426
10427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10428 {
10429 return qe_invalid;
10430 }
10431
10432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10433 {
10434 return qe_invalid;
10435 }
10436
10437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10438 {
10439 96 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10440 96 }
10441 96 }
10442
10443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>1)
10444 {
10445
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10446 {
10447
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10448 {
10449 return qe_invalid;
10450 }
10451
10452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10453 {
10454 return qe_invalid;
10455 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10458 {
10459 return qe_invalid;
10460 }
10461
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10463 {
10464 96 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10465 96 }
10466 96 }
10467 24 }
10468
10469
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10470 {
10471
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10472 {
10473 return qe_invalid;
10474 }
10475
10476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10477 {
10478 return qe_invalid;
10479 }
10480
10481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10482 {
10483 return qe_invalid;
10484 }
10485
10486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10487 {
10488 96 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10489 96 }
10490 96 }
10491
10492
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10493 {
10494
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10495 {
10496 return qe_invalid;
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10500 {
10501 return qe_invalid;
10502 }
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10505 {
10506 return qe_invalid;
10507 }
10508
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10510 {
10511 96 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10512 96 }
10513 96 }
10514
10515
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tile,f,keepdata))
10516 {
10517 return qe_invalid;
10518 }
10519
10520 24 flip=0;
10521
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>0)
10523 {
10524
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&flip,f,keepdata))
10525 {
10526 return qe_invalid;
10527 }
10528 24 }
10529
10530
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&extend,f,keepdata))
10531 {
10532 return qe_invalid;
10533 }
10534
10535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
10536 {
10537 24 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10538 24 }
10539
10540
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(v_herosprites>0)
10541 {
10542 24 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10543
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for(int32_t i=0; i<2; i++)
10544 {
10545
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 48 times.
192 for(int32_t j=0; j<num_holdsprs; j++)
10546 {
10547
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f,keepdata))
10548 {
10549 return qe_invalid;
10550 }
10551
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f,keepdata))
10553 {
10554 return qe_invalid;
10555 }
10556
10557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f,keepdata))
10558 {
10559 return qe_invalid;
10560 }
10561
10562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(keepdata)
10563 {
10564 144 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10565 144 }
10566 144 }
10567 48 }
10568 24 }
10569 else
10570 {
10571 for(int32_t i=0; i<2; i++)
10572 {
10573 if(!p_igetl(&tile,f,keepdata))
10574 {
10575 return qe_invalid;
10576 }
10577
10578 if(!p_igetl(&tile2,f,keepdata))
10579 {
10580 return qe_invalid;
10581 }
10582
10583 if(!p_getc(&extend,f,keepdata))
10584 {
10585 return qe_invalid;
10586 }
10587
10588 if(keepdata)
10589 {
10590 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10591 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10592 }
10593 }
10594 }
10595
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>2)
10597 {
10598
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10599 {
10600
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10601 {
10602 return qe_invalid;
10603 }
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10606 {
10607 return qe_invalid;
10608 }
10609
10610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10611 {
10612 return qe_invalid;
10613 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10616 {
10617 96 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10618 96 }
10619 96 }
10620 24 }
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>3)
10623 {
10624
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t i=0; i<4; i++)
10625 {
10626
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10632 {
10633 return qe_invalid;
10634 }
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10637 {
10638 return qe_invalid;
10639 }
10640
10641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10642 {
10643 96 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10644 96 }
10645 96 }
10646 24 }
10647
10648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(v_herosprites>4)
10649 {
10650
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&dummy_byte,f,keepdata))
10651 {
10652 return qe_invalid;
10653 }
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata)
10656 {
10657 24 zinit.hero_swim_speed=(byte)dummy_byte;
10658 24 }
10659 24 }
10660
10661
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(v_herosprites>6)
10662 {
10663
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10672 return qe_invalid;
10673
10674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10675 {
10676 96 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 96 }
10678 96 }
10679
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10682 return qe_invalid;
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10685 return qe_invalid;
10686
10687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10688 return qe_invalid;
10689
10690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10691 {
10692 96 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10693 96 }
10694 96 }
10695
10696
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10697 {
10698
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10699 return qe_invalid;
10700
10701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10702 return qe_invalid;
10703
10704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10705 return qe_invalid;
10706
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10708 {
10709 96 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10710 96 }
10711 96 }
10712
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10713 {
10714
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10715 return qe_invalid;
10716
10717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10718 return qe_invalid;
10719
10720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10721 return qe_invalid;
10722
10723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10724 {
10725 96 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10726 96 }
10727 96 }
10728
10729
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10730 {
10731
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10732 return qe_invalid;
10733
10734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10735 return qe_invalid;
10736
10737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10738 return qe_invalid;
10739
10740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10741 {
10742 96 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10743 96 }
10744 96 }
10745
10746
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10747 {
10748
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10749 return qe_invalid;
10750
10751
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10752 return qe_invalid;
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10755 return qe_invalid;
10756
10757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10758 {
10759 96 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 96 }
10761 96 }
10762
10763
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10764 {
10765
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10766 return qe_invalid;
10767
10768
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10769 return qe_invalid;
10770
10771
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10772 return qe_invalid;
10773
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10775 {
10776 96 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10777 96 }
10778 96 }
10779
10780
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10781 {
10782
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10783 return qe_invalid;
10784
10785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10786 return qe_invalid;
10787
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10789 return qe_invalid;
10790
10791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10792 {
10793 96 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 96 }
10795 96 }
10796
10797
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10798 {
10799
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10800 return qe_invalid;
10801
10802
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10803 return qe_invalid;
10804
10805
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10806 return qe_invalid;
10807
10808 96 byte frames = 0;
10809
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 88 times.
96 if(v_herosprites > 15)
10810 {
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&frames,f,keepdata))
10812 return qe_invalid;
10813 88 }
10814
10815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10816 {
10817 96 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10818 96 liftingspr[q][spr_frames] = frames;
10819 96 }
10820 96 }
10821
10822
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10823 {
10824
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10825 return qe_invalid;
10826
10827
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10834 {
10835 96 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10836 96 }
10837 96 }
10838
10839
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetl(&tile,f,keepdata))
10842 return qe_invalid;
10843
10844
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10845 return qe_invalid;
10846
10847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10848 return qe_invalid;
10849
10850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10851 {
10852 96 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10853 96 }
10854 96 }
10855
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10858 return qe_invalid;
10859
10860
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10864 return qe_invalid;
10865
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10867 {
10868 96 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10869 96 }
10870 96 }
10871
10872
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10878 return qe_invalid;
10879
10880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10881 return qe_invalid;
10882
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10884 {
10885 96 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10886 96 }
10887 96 }
10888
10889
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10890 {
10891
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10892 return qe_invalid;
10893
10894
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10895 return qe_invalid;
10896
10897
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10901 {
10902 96 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 96 }
10904 96 }
10905
10906
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10915 return qe_invalid;
10916
10917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10918 {
10919 96 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 96 }
10921 96 }
10922
10923
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10924 {
10925
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10926 return qe_invalid;
10927
10928
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10935 {
10936 96 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10937 96 }
10938 96 }
10939
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10940 {
10941
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10948 return qe_invalid;
10949
10950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10951 {
10952 96 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10953 96 }
10954 96 }
10955
10956
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10957 {
10958
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10959 return qe_invalid;
10960
10961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
10962 return qe_invalid;
10963
10964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10965 return qe_invalid;
10966
10967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10968 {
10969 96 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10970 96 }
10971 96 }
10972
10973
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10974 {
10975
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
10976 return qe_invalid;
10977
10978
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10979 return qe_invalid;
10980
10981
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
10982 return qe_invalid;
10983
10984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
10985 {
10986 96 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10987 96 }
10988 96 }
10989
10990
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
10991 {
10992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetl(&tile,f,keepdata))
10993 return qe_invalid;
10994
10995
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
10996 return qe_invalid;
10997
10998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
10999 return qe_invalid;
11000
11001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11002 {
11003 96 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11004 96 }
11005 96 }
11006
11007
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11008 {
11009
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11010 return qe_invalid;
11011
11012
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
11013 return qe_invalid;
11014
11015
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
11016 return qe_invalid;
11017
11018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11019 {
11020 96 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11021 96 }
11022 96 }
11023
11024
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11025 {
11026
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11027 return qe_invalid;
11028
11029
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
11030 return qe_invalid;
11031
11032
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11036 {
11037 96 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11038 96 }
11039 96 }
11040
11041
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11042 {
11043
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11044 return qe_invalid;
11045
11046
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&flip,f,keepdata))
11047 return qe_invalid;
11048
11049
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&extend,f,keepdata))
11050 return qe_invalid;
11051
11052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11053 {
11054 96 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11055 96 }
11056 96 }
11057
11058
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
96 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11059 {
11060
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!p_igetl(&tile,f,keepdata))
11061 return qe_invalid;
11062
11063
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!p_getc(&flip,f,keepdata))
11064 return qe_invalid;
11065
11066
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!p_getc(&extend,f,keepdata))
11067 return qe_invalid;
11068
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(keepdata)
11070 {
11071 72 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11072 72 }
11073 72 }
11074 24 }
11075 else if(keepdata)
11076 {
11077 memset(frozenspr, 0, sizeof(frozenspr));
11078 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11079 memset(onfirespr, 0, sizeof(onfirespr));
11080 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11081 memset(diggingspr, 0, sizeof(diggingspr));
11082 memset(usingrodspr, 0, sizeof(usingrodspr));
11083 memset(usingcanespr, 0, sizeof(usingcanespr));
11084 memset(pushingspr, 0, sizeof(pushingspr));
11085 memset(liftingspr, 0, sizeof(liftingspr));
11086 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11087 memset(stunnedspr, 0, sizeof(stunnedspr));
11088 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11089 memset(fallingspr, 0, sizeof(fallingspr));
11090 memset(shockedspr, 0, sizeof(shockedspr));
11091 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11092 memset(pullswordspr, 0, sizeof(pullswordspr));
11093 memset(readingspr, 0, sizeof(readingspr));
11094 memset(slash180spr, 0, sizeof(slash180spr));
11095 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11096 memset(dashspr, 0, sizeof(dashspr));
11097 memset(bonkspr, 0, sizeof(bonkspr));
11098 memset(medallionsprs, 0, sizeof(medallionsprs));
11099 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11100 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11101 for(int32_t q = 0; q < 4; ++q)
11102 {
11103 for(int32_t p = 0; p < 3; ++p)
11104 {
11105 drowningspr[q][p] = divespr[q][p];
11106 drowning_lavaspr[q][p] = divespr[q][p];
11107 }
11108 }
11109 }
11110
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 8)
11111 {
11112
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11113 {
11114
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11115 return qe_invalid;
11116
11117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11118 return qe_invalid;
11119
11120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11121 return qe_invalid;
11122
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11124 {
11125 96 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11126 96 }
11127 96 }
11128 24 }
11129 else if (keepdata)
11130 {
11131 memset(sideswimspr, 0, sizeof(sideswimspr));
11132 }
11133
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 9)
11134 {
11135
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11136 {
11137
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11138 return qe_invalid;
11139
11140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11141 return qe_invalid;
11142
11143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11144 return qe_invalid;
11145
11146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11147 {
11148 96 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11149 96 }
11150 96 }
11151
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11152 {
11153
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11154 return qe_invalid;
11155
11156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11157 return qe_invalid;
11158
11159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11160 return qe_invalid;
11161
11162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11163 {
11164 96 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11165 96 }
11166 96 }
11167
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11168 {
11169
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11170 return qe_invalid;
11171
11172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11173 return qe_invalid;
11174
11175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11176 return qe_invalid;
11177
11178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11179 {
11180 96 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11181 96 }
11182 96 }
11183
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11184 {
11185
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11186 return qe_invalid;
11187
11188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11189 return qe_invalid;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11192 return qe_invalid;
11193
11194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11195 {
11196 96 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11197 96 }
11198 96 }
11199 24 }
11200 else if (keepdata)
11201 {
11202 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11203 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11204 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11205 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11206 }
11207
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 10)
11208 {
11209
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11210 {
11211 int32_t hmr;
11212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetl(&hmr,f,keepdata))
11213 return qe_invalid;
11214
11215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11216 {
11217 96 hammeroffsets[q] = hmr;
11218 96 }
11219 96 }
11220 24 }
11221 else if (keepdata)
11222 {
11223 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11224 }
11225
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 11)
11226 {
11227
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
96 for(int32_t q = 0; q < 3; ++q)
11228 {
11229
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!p_igetl(&tile,f,keepdata))
11230 return qe_invalid;
11231
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(!p_getc(&flip,f,keepdata))
11233 return qe_invalid;
11234
11235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(!p_getc(&extend,f,keepdata))
11236 return qe_invalid;
11237
11238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(keepdata)
11239 {
11240 72 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11241 72 }
11242 72 }
11243 24 }
11244 else if (keepdata)
11245 {
11246 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11247 }
11248
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 12)
11249 {
11250
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tile,f,keepdata))
11251 return qe_invalid;
11252
11253
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&flip,f,keepdata))
11254 return qe_invalid;
11255
11256
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&extend,f,keepdata))
11257 return qe_invalid;
11258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (keepdata)
11259 {
11260 24 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11261 24 }
11262
11263 24 }
11264 else if (keepdata)
11265 {
11266 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11267 }
11268
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 13)
11269 {
11270
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11271 {
11272
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11273 return qe_invalid;
11274
11275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11276 return qe_invalid;
11277
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11279 return qe_invalid;
11280
11281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11282 {
11283 96 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11284 96 }
11285 96 }
11286 24 }
11287 else if (keepdata)
11288 {
11289 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11290 }
11291
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 14)
11292 {
11293
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
120 for(int32_t q = 0; q < 4; ++q)
11294 {
11295
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tile,f,keepdata))
11296 return qe_invalid;
11297
11298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&flip,f,keepdata))
11299 return qe_invalid;
11300
11301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&extend,f,keepdata))
11302 return qe_invalid;
11303
11304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
11305 {
11306 96 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11307 96 }
11308 96 }
11309 24 }
11310 else if (keepdata)
11311 {
11312 memset(revslashspr, 0, sizeof(revslashspr));
11313 }
11314
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (v_herosprites > 7)
11315 {
11316 24 int32_t num_defense = wMax;
11317 24 byte def = 0;
11318
11319 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11320 /*if(v_herosprites > [x])
11321 * {
11322 * num_defense = 146 //value of wMax on version 8
11323 * }
11324 */
11325
11326
2/2
✓ Branch 0 taken 3504 times.
✓ Branch 1 taken 24 times.
3528 for (int32_t q = 0; q < num_defense; q++)
11327 {
11328
1/2
✓ Branch 0 taken 3504 times.
✗ Branch 1 not taken.
3504 if (!p_getc(&def, f, keepdata))
11329 return qe_invalid;
11330
11331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3504 times.
3504 if (keepdata)
11332 {
11333 3504 hero_defence[q] = def;
11334 3504 }
11335 3504 }
11336 24 }
11337 else if (keepdata)
11338 {
11339 int32_t num_defense = wMax;
11340 for (int32_t q = 0; q < num_defense; q++)
11341 {
11342 hero_defence[q] = 0;
11343 }
11344 }
11345 24 }
11346
11347
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 15 times.
24 if(keepdata && FFCore.quest_format[vInitData] < 34)
11348 {
11349 15 bool fastswim = zinit.hero_swim_speed > 60;
11350 // '2/3' or '1/2'
11351 15 zinit.hero_swim_mult = fastswim ? 2 : 1;
11352 15 zinit.hero_swim_div = fastswim ? 3 : 2;
11353 15 }
11354 24 return 0;
11355 24 }
11356
11357
11358 99 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11359 {
11360 //these are here to bypass compiler warnings about unused arguments
11361 99 Header=Header;
11362
11363 dword dummy;
11364 99 word s_version=0, s_cversion=0;
11365
11366 //section version info
11367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
11368 {
11369 return qe_invalid;
11370 }
11371
11372 99 FFCore.quest_format[vHeroSprites] = s_version;
11373
11374 //al_trace("Player sprites version %d\n", s_version);
11375
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
11376 {
11377 return qe_invalid;
11378 }
11379
11380 //section size
11381
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
11382 {
11383 return qe_invalid;
11384 }
11385
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if ( s_version >= 6 )
11386 {
11387 //al_trace("Reading Player Sprites v6\n");
11388 24 return readherosprites3(f, s_version, dummy, keepdata);
11389 }
11390 75 else return readherosprites2(f, s_version, dummy, keepdata);
11391 99 }
11392
11393 99 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11394 {
11395 int32_t dummy;
11396 99 word s_version=0, s_cversion=0;
11397
11398 //section version info
11399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
11400 {
11401 return qe_invalid;
11402 }
11403
11404 99 FFCore.quest_format[vSubscreen] = s_version;
11405
11406 //al_trace("Subscreens version %d\n", s_version);
11407
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
11408 {
11409 return qe_invalid;
11410 }
11411
11412 //section size
11413
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
11414 {
11415 return qe_invalid;
11416 }
11417
11418 //finally... section data
11419
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 99 times.
12771 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11420 {
11421 12672 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11422
11423
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(ret!=0) return ret;
11424 12672 }
11425
11426 99 return 0;
11427 99 }
11428
11429 12672 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11430 {
11431 12672 int32_t numsub=0;
11432 12672 byte temp_ss=0;
11433 subscreen_object temp_sub_stack;
11434 12672 subscreen_object *temp_sub = &temp_sub_stack;
11435
11436 char tempname[64];
11437
11438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(!pfread(tempname,64,f,true))
11439 {
11440 return qe_invalid;
11441 }
11442
11443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(s_version > 1)
11444 {
11445
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(!p_getc(&temp_ss,f,keepdata))
11446 {
11447 return qe_invalid;
11448 }
11449 12672 }
11450
11451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12672 times.
12672 if(s_version < 4)
11452 {
11453 uint8_t tmp=0;
11454
11455 if(!p_getc(&tmp,f,true))
11456 {
11457 return qe_invalid;
11458 }
11459
11460 numsub = (int32_t)tmp;
11461 }
11462 else
11463 {
11464 word tmp;
11465
11466
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if(!p_igetw(&tmp, f, true))
11467 {
11468 return qe_invalid;
11469 }
11470
11471 12672 numsub = (int32_t)tmp;
11472 }
11473
11474 int32_t j;
11475
11476
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33615 times.
✓ Branch 2 taken 20943 times.
✓ Branch 3 taken 12672 times.
33615 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11477 {
11478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20943 times.
20943 if(keepdata)
11479 {
11480 20943 memset(temp_sub,0,sizeof(subscreen_object));
11481
11482
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 19774 times.
20943 switch(custom_subscreen[i].objects[j].type)
11483 {
11484 case ssoTEXT:
11485 case ssoTEXTBOX:
11486 case ssoCURRENTITEMTEXT:
11487 case ssoCURRENTITEMCLASSTEXT:
11488
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1169 times.
✓ Branch 2 taken 1169 times.
✗ Branch 3 not taken.
1169 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11489
11490 //fall through
11491 default:
11492 20943 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11493 20943 break;
11494 }
11495 20943 }
11496
11497
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->type),f,true))
11498 {
11499 return qe_invalid;
11500 }
11501
11502
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->pos),f,keepdata))
11503 {
11504 return qe_invalid;
11505 }
11506
11507
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(s_version < 5)
11508 {
11509 switch(temp_sub->pos)
11510 {
11511 case 0:
11512 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11513 break;
11514
11515 case 1:
11516 temp_sub->pos = sspUP;
11517 break;
11518
11519 case 2:
11520 temp_sub->pos = sspDOWN;
11521 break;
11522
11523 default:
11524 temp_sub->pos = 0;
11525 }
11526 }
11527
11528
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->x),f,keepdata))
11529 {
11530 return qe_invalid;
11531 }
11532
11533
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->y),f,keepdata))
11534 {
11535 return qe_invalid;
11536 }
11537
11538
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->w),f,keepdata))
11539 {
11540 return qe_invalid;
11541 }
11542
11543
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->h),f,keepdata))
11544 {
11545 return qe_invalid;
11546 }
11547
11548
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11549 {
11550 return qe_invalid;
11551 }
11552
11553
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11554 {
11555 return qe_invalid;
11556 }
11557
11558
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11559 {
11560 return qe_invalid;
11561 }
11562
11563
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11564 {
11565 return qe_invalid;
11566 }
11567
11568
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11569 {
11570 return qe_invalid;
11571 }
11572
11573
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11574 {
11575 return qe_invalid;
11576 }
11577
11578
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11579 {
11580 return qe_invalid;
11581 }
11582
11583
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11584 {
11585 return qe_invalid;
11586 }
11587
11588
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11589 {
11590 return qe_invalid;
11591 }
11592
11593
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11594 {
11595 return qe_invalid;
11596 }
11597
11598
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11599 {
11600 return qe_invalid;
11601 }
11602
11603
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11604 {
11605 return qe_invalid;
11606 }
11607
11608
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11609 {
11610 return qe_invalid;
11611 }
11612
11613
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11614 {
11615 return qe_invalid;
11616 }
11617
11618
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11619 {
11620 return qe_invalid;
11621 }
11622
11623
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11624 {
11625 return qe_invalid;
11626 }
11627
11628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20943 times.
20943 if(s_version < 2)
11629 {
11630 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11631 {
11632 return qe_invalid;
11633 }
11634
11635 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11636 {
11637 return qe_invalid;
11638 }
11639
11640 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11641 {
11642 return qe_invalid;
11643 }
11644 }
11645 else
11646 {
11647
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->speed),f,keepdata))
11648 {
11649 return qe_invalid;
11650 }
11651
11652
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_getc(&(temp_sub->delay),f,keepdata))
11653 {
11654 return qe_invalid;
11655 }
11656
11657
1/2
✓ Branch 0 taken 20943 times.
✗ Branch 1 not taken.
20943 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11658 {
11659 return qe_invalid;
11660 }
11661 }
11662
11663 20943 int32_t temp_size=0;
11664
11665 // bool deletets = false;
11666
4/4
✓ Branch 0 taken 8810 times.
✓ Branch 1 taken 1659 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 143 times.
20943 switch(temp_sub->type)
11667 {
11668 case ssoTEXT:
11669 case ssoTEXTBOX:
11670 case ssoCURRENTITEMTEXT:
11671 case ssoCURRENTITEMCLASSTEXT:
11672 word temptempsize;
11673 /*uint8_t temp1;
11674 uint8_t temp2;
11675 temp2 = 0;
11676 if(!p_getc(&temp1,f,true))
11677 {
11678 return qe_invalid;
11679 }
11680 if(temp1)
11681 {
11682
11683 if(!p_getc(&temp2,f,true))
11684 {
11685 return qe_invalid;
11686 }
11687 }*/
11688
11689
1/2
✓ Branch 0 taken 1659 times.
✗ Branch 1 not taken.
1659 if(!p_igetw(&temptempsize,f,true))
11690 {
11691 return qe_invalid;
11692 }
11693
11694 //temptempsize = temp1 + (temp2 << 8);
11695 1659 temp_size = (int32_t)temptempsize;
11696
11697 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1659 times.
1659 if(keepdata)
11699 {
11700 1659 uint32_t char_length = temp_size+1;
11701 1659 temp_sub->dp1 = new char[char_length]; //memory not freed
11702
11703 //deletets = true; //obsolete
11704 1659 }
11705
11706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1659 times.
1659 if(temp_size)
11707 {
11708
1/2
✓ Branch 0 taken 1659 times.
✗ Branch 1 not taken.
1659 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11709 {
11710 return qe_invalid;
11711 }
11712 1659 }
11713
11714 1659 break;
11715
11716 case ssoLIFEMETER:
11717
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11718 temp_sub->d3 = 1;
11719
11720
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11721 {
11722 return qe_invalid;
11723 }
11724
11725 143 break;
11726
11727
11728 case ssoCURRENTITEM:
11729
11730
1/2
✓ Branch 0 taken 8810 times.
✗ Branch 1 not taken.
8810 if(s_version < 6)
11731 {
11732 switch(temp_sub->d1)
11733 {
11734 case ssiBOMB:
11735 temp_sub->d1 = itype_bomb;
11736 break;
11737
11738 case ssiSWORD:
11739 temp_sub->d1 = itype_sword;
11740 break;
11741
11742 case ssiSHIELD:
11743 temp_sub->d1 = itype_shield;
11744 break;
11745
11746 case ssiCANDLE:
11747 temp_sub->d1 = itype_candle;
11748 break;
11749
11750 case ssiLETTER:
11751 temp_sub->d1 = itype_letter;
11752 break;
11753
11754 case ssiPOTION:
11755 temp_sub->d1 = itype_potion;
11756 break;
11757
11758 case ssiLETTERPOTION:
11759 temp_sub->d1 = itype_letterpotion;
11760 break;
11761
11762 case ssiBOW:
11763 temp_sub->d1 = itype_bow;
11764 break;
11765
11766 case ssiARROW:
11767 temp_sub->d1 = itype_arrow;
11768 break;
11769
11770 case ssiBOWANDARROW:
11771 temp_sub->d1 = itype_bowandarrow;
11772 break;
11773
11774 case ssiBAIT:
11775 temp_sub->d1 = itype_bait;
11776 break;
11777
11778 case ssiRING:
11779 temp_sub->d1 = itype_ring;
11780 break;
11781
11782 case ssiBRACELET:
11783 temp_sub->d1 = itype_bracelet;
11784 break;
11785
11786 case ssiMAP:
11787 temp_sub->d1 = itype_map;
11788 break;
11789
11790 case ssiCOMPASS:
11791 temp_sub->d1 = itype_compass;
11792 break;
11793
11794 case ssiBOSSKEY:
11795 temp_sub->d1 = itype_bosskey;
11796 break;
11797
11798 case ssiMAGICKEY:
11799 temp_sub->d1 = itype_magickey;
11800 break;
11801
11802 case ssiBRANG:
11803 temp_sub->d1 = itype_brang;
11804 break;
11805
11806 case ssiWAND:
11807 temp_sub->d1 = itype_wand;
11808 break;
11809
11810 case ssiRAFT:
11811 temp_sub->d1 = itype_raft;
11812 break;
11813
11814 case ssiLADDER:
11815 temp_sub->d1 = itype_ladder;
11816 break;
11817
11818 case ssiWHISTLE:
11819 temp_sub->d1 = itype_whistle;
11820 break;
11821
11822 case ssiBOOK:
11823 temp_sub->d1 = itype_book;
11824 break;
11825
11826 case ssiWALLET:
11827 temp_sub->d1 = itype_wallet;
11828 break;
11829
11830 case ssiSBOMB:
11831 temp_sub->d1 = itype_sbomb;
11832 break;
11833
11834 case ssiHCPIECE:
11835 temp_sub->d1 = itype_heartpiece;
11836 break;
11837
11838 case ssiAMULET:
11839 temp_sub->d1 = itype_amulet;
11840 break;
11841
11842 case ssiFLIPPERS:
11843 temp_sub->d1 = itype_flippers;
11844 break;
11845
11846 case ssiHOOKSHOT:
11847 temp_sub->d1 = itype_hookshot;
11848 break;
11849
11850 case ssiLENS:
11851 temp_sub->d1 = itype_lens;
11852 break;
11853
11854 case ssiHAMMER:
11855 temp_sub->d1 = itype_hammer;
11856 break;
11857
11858 case ssiBOOTS:
11859 temp_sub->d1 = itype_boots;
11860 break;
11861
11862 case ssiDIVINEFIRE:
11863 temp_sub->d1 = itype_divinefire;
11864 break;
11865
11866 case ssiDIVINEESCAPE:
11867 temp_sub->d1 = itype_divineescape;
11868 break;
11869
11870 case ssiDIVINEPROTECTION:
11871 temp_sub->d1 = itype_divineprotection;
11872 break;
11873
11874 case ssiQUIVER:
11875 temp_sub->d1 = itype_quiver;
11876 break;
11877
11878 case ssiBOMBBAG:
11879 temp_sub->d1 = itype_bombbag;
11880 break;
11881
11882 case ssiCBYRNA:
11883 temp_sub->d1 = itype_cbyrna;
11884 break;
11885
11886 case ssiROCS:
11887 temp_sub->d1 = itype_rocs;
11888 break;
11889
11890 case ssiHOVERBOOTS:
11891 temp_sub->d1 = itype_hoverboots;
11892 break;
11893
11894 case ssiSPINSCROLL:
11895 temp_sub->d1 = itype_spinscroll;
11896 break;
11897
11898 case ssiCROSSSCROLL:
11899 temp_sub->d1 = itype_crossscroll;
11900 break;
11901
11902 case ssiQUAKESCROLL:
11903 temp_sub->d1 = itype_quakescroll;
11904 break;
11905
11906 case ssiWHISPRING:
11907 temp_sub->d1 = itype_whispring;
11908 break;
11909
11910 case ssiCHARGERING:
11911 temp_sub->d1 = itype_chargering;
11912 break;
11913
11914 case ssiPERILSCROLL:
11915 temp_sub->d1 = itype_perilscroll;
11916 break;
11917
11918 case ssiWEALTHMEDAL:
11919 temp_sub->d1 = itype_wealthmedal;
11920 break;
11921
11922 case ssiHEARTRING:
11923 temp_sub->d1 = itype_heartring;
11924 break;
11925
11926 case ssiMAGICRING:
11927 temp_sub->d1 = itype_magicring;
11928 break;
11929
11930 case ssiSPINSCROLL2:
11931 temp_sub->d1 = itype_spinscroll2;
11932 break;
11933
11934 case ssiQUAKESCROLL2:
11935 temp_sub->d1 = itype_quakescroll2;
11936 break;
11937
11938 case ssiAGONY:
11939 temp_sub->d1 = itype_agony;
11940 break;
11941
11942 case ssiSTOMPBOOTS:
11943 temp_sub->d1 = itype_stompboots;
11944 break;
11945
11946 case ssiWHIMSICALRING:
11947 temp_sub->d1 = itype_whimsicalring;
11948 break;
11949
11950 case ssiPERILRING:
11951 temp_sub->d1 = itype_perilring;
11952 break;
11953
11954 default:
11955 temp_sub->d1 += itype_custom1 - ssiMAX;
11956 }
11957 }
11958
11959 //fall-through
11960 default:
11961
1/2
✓ Branch 0 taken 19141 times.
✗ Branch 1 not taken.
19141 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11962 {
11963 return qe_invalid;
11964 }
11965
11966 19141 break;
11967 }
11968
11969
2/2
✓ Branch 0 taken 12427 times.
✓ Branch 1 taken 8516 times.
20943 if(s_version < 7)
11970 {
11971
3/3
✓ Branch 0 taken 7857 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8516 switch(temp_sub->type)
11972 {
11973 case ssoMAGICGAUGE:
11974 {
11975
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11976 192 temp_sub->d9 = -1; //-1 now represents 'always'
11977 227 break;
11978 }
11979 case ssoLIFEGAUGE:
11980 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11981 432 break;
11982 }
11983 8516 }
11984
11985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20943 times.
20943 if(keepdata)
11986 {
11987
3/3
✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 18376 times.
✓ Branch 2 taken 908 times.
20943 switch(temp_sub->type)
11988 {
11989 case ssoTEXT:
11990 case ssoTEXTBOX:
11991 case ssoCURRENTITEMTEXT:
11992 case ssoCURRENTITEMCLASSTEXT:
11993
1/4
✓ Branch 0 taken 1659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1659 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11994
11995 1659 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11996 1659 custom_subscreen[i].objects[j].dp1 = NULL;
11997 1659 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11998 1659 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11999 1659 break;
12000
12001 case ssoCOUNTER:
12002
1/2
✓ Branch 0 taken 908 times.
✗ Branch 1 not taken.
908 if(s_version<3)
12003 {
12004 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12005 temp_sub->d8=0;
12006 }
12007
12008 default:
12009 19284 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12010 19284 break;
12011 }
12012
12013 20943 strcpy(custom_subscreen[i].name, tempname);
12014 20943 custom_subscreen[i].ss_type = temp_ss;
12015 20943 }
12016 20943 }
12017
12018
2/2
✓ Branch 0 taken 3223089 times.
✓ Branch 1 taken 12672 times.
3235761 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12019 {
12020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3223089 times.
3223089 if(keepdata)
12021 {
12022 //clear all unused object in this subscreen -DD
12023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3223089 times.
3223089 switch(custom_subscreen[i].objects[j].type)
12024 {
12025 case ssoTEXT:
12026 case ssoTEXTBOX:
12027 case ssoCURRENTITEMTEXT:
12028 case ssoCURRENTITEMCLASSTEXT:
12029 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12030
12031 //fall through
12032 default:
12033 3223089 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12034 3223089 break;
12035 }
12036 3223089 }
12037 3223089 }
12038
12039 12672 return 0;
12040 12672 }
12041
12042 2816 void reset_subscreen(subscreen_group *tempss)
12043 {
12044
2/2
✓ Branch 0 taken 720896 times.
✓ Branch 1 taken 2816 times.
723712 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12045 {
12046
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 720754 times.
720896 switch(tempss->objects[i].type)
12047 {
12048 case ssoTEXT:
12049 case ssoTEXTBOX:
12050 case ssoCURRENTITEMTEXT:
12051 case ssoCURRENTITEMCLASSTEXT:
12052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12053
12054 //fall through
12055 default:
12056 720896 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12057 720896 break;
12058 }
12059 720896 }
12060 2816 }
12061
12062 22 void reset_subscreens()
12063 {
12064
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 22 times.
2838 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12065 {
12066 2816 reset_subscreen(&custom_subscreen[i]);
12067 2816 }
12068 22 }
12069
12070 22 int32_t setupsubscreens()
12071 {
12072 22 reset_subscreens();
12073 22 int32_t tempsubscreen=zinit.subscreen;
12074 subscreen_object *tempsub;
12075
12076
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(tempsubscreen>=ssdtMAX)
12077 {
12078 tempsubscreen=0;
12079 }
12080
12081
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
22 switch(tempsubscreen)
12082 {
12083 case ssdtOLD:
12084 case ssdtNEWSUBSCR:
12085 case ssdtREV2:
12086 case ssdtBSZELDA:
12087 case ssdtBSZELDAMODIFIED:
12088 case ssdtBSZELDAENHANCED:
12089 case ssdtBSZELDACOMPLETE:
12090 {
12091 22 tempsub = default_subscreen_active[tempsubscreen][0];
12092 int32_t i;
12093
12094
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1452 times.
✓ Branch 2 taken 1430 times.
✓ Branch 3 taken 22 times.
1452 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12095 {
12096
2/3
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1370 times.
✗ Branch 2 not taken.
1430 switch(tempsub[i].type)
12097 {
12098 case ssoTEXT:
12099 case ssoTEXTBOX:
12100 case ssoCURRENTITEMTEXT:
12101 case ssoCURRENTITEMCLASSTEXT:
12102
1/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12103
12104 60 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12105 60 custom_subscreen[0].objects[i].dp1 = NULL;
12106 60 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12107 60 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12108 60 break;
12109
12110 case ssoLIFEMETER:
12111 {
12112 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12113
12114 if(get_bit(deprecated_rules, 12) != 0)
12115 custom_subscreen[0].objects[i].d3=1;
12116 else
12117 custom_subscreen[0].objects[i].d3=0;
12118
12119 break;
12120 }
12121 /*
12122 case ssoTRIFRAME:
12123 {
12124 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12125 custom_subscreen[0].objects[i].d1 = 8594;
12126 custom_subscreen[0].objects[i].d2 = 8;
12127 custom_subscreen[0].objects[i].d3 = 8771;
12128 custom_subscreen[0].objects[i].d4 = 8;
12129 custom_subscreen[0].objects[i].d5 = 1;
12130 custom_subscreen[0].objects[i].d6 = 1;
12131 break;
12132 }*/
12133
12134 default:
12135 1370 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12136 1370 break;
12137 }
12138 1430 }
12139
12140 22 custom_subscreen[0].ss_type=sstACTIVE;
12141 22 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12142 22 tempsub = default_subscreen_active[tempsubscreen][1];
12143
12144
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1452 times.
✓ Branch 2 taken 1430 times.
✓ Branch 3 taken 22 times.
1452 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12145 {
12146
2/3
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1352 times.
✗ Branch 2 not taken.
1430 switch(tempsub[i].type)
12147 {
12148 case ssoTEXT:
12149 case ssoTEXTBOX:
12150 case ssoCURRENTITEMTEXT:
12151 case ssoCURRENTITEMCLASSTEXT:
12152
1/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12153
12154 78 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12155 78 custom_subscreen[1].objects[i].dp1 = NULL;
12156 78 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12157 78 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12158 78 break;
12159
12160 case ssoLIFEMETER:
12161 {
12162 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12163
12164 if(get_bit(deprecated_rules, 12) != 0)
12165 custom_subscreen[1].objects[i].d3=1;
12166 else
12167 custom_subscreen[1].objects[i].d3=0;
12168
12169 break;
12170 }
12171 /*
12172 case ssoTRIFRAME:
12173 {
12174 custom_subscreen[1].objects[i].d1 = 8594;
12175 custom_subscreen[1].objects[i].d2 = 8;
12176 custom_subscreen[1].objects[i].d3 = 8771;
12177 custom_subscreen[1].objects[i].d4 = 8;
12178 custom_subscreen[1].objects[i].d5 = 1;
12179 custom_subscreen[1].objects[i].d6 = 1;
12180 break;
12181 }*/
12182
12183 default:
12184 1352 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12185 1352 break;
12186 }
12187 1430 }
12188
12189 22 custom_subscreen[1].ss_type=sstACTIVE;
12190 22 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12191 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12192 22 tempsub = default_subscreen_passive[tempsubscreen][0];
12193
12194
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
✓ Branch 2 taken 440 times.
✓ Branch 3 taken 22 times.
462 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12195 {
12196
3/3
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 22 times.
440 switch(tempsub[i].type)
12197 {
12198 case ssoTEXT:
12199 case ssoTEXTBOX:
12200 case ssoCURRENTITEMTEXT:
12201 case ssoCURRENTITEMCLASSTEXT:
12202
1/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12203
12204 66 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12205 66 custom_subscreen[2].objects[i].dp1 = NULL;
12206 66 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12207 66 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12208 66 break;
12209
12210 case ssoLIFEMETER:
12211 {
12212 22 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12213
12214
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 15 times.
22 if(get_bit(deprecated_rules, 12) != 0)
12215 7 custom_subscreen[2].objects[i].d3=1;
12216 else
12217 15 custom_subscreen[2].objects[i].d3=0;
12218
12219 22 break;
12220 }
12221
12222 default:
12223 352 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12224 352 break;
12225 }
12226 440 }
12227
12228 22 custom_subscreen[2].ss_type=sstPASSIVE;
12229 22 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12230 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12231 22 tempsub = default_subscreen_passive[tempsubscreen][1];
12232
12233
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 22 times.
440 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12234 {
12235
3/3
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22 times.
418 switch(tempsub[i].type)
12236 {
12237 case ssoTEXT:
12238 case ssoTEXTBOX:
12239 case ssoCURRENTITEMTEXT:
12240 case ssoCURRENTITEMCLASSTEXT:
12241
1/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12242
12243 66 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12244 66 custom_subscreen[3].objects[i].dp1 = NULL;
12245 66 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12246 66 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12247 66 break;
12248
12249 case ssoLIFEMETER:
12250 {
12251 22 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12252
12253
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 15 times.
22 if(get_bit(deprecated_rules, 12) != 0)
12254 7 custom_subscreen[3].objects[i].d3=1;
12255 else
12256 15 custom_subscreen[3].objects[i].d3=0;
12257
12258 22 break;
12259 }
12260
12261 default:
12262 330 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12263 330 break;
12264 }
12265 418 }
12266
12267 22 custom_subscreen[3].ss_type=sstPASSIVE;
12268 22 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12269 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12270 22 break;
12271 }
12272
12273 case ssdtZ3:
12274 {
12275 tempsub = z3_active_a;
12276 int32_t i;
12277
12278 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12279 {
12280 switch(tempsub[i].type)
12281 {
12282 case ssoTEXT:
12283 case ssoTEXTBOX:
12284 case ssoCURRENTITEMTEXT:
12285 case ssoCURRENTITEMCLASSTEXT:
12286 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12287
12288 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12289 custom_subscreen[0].objects[i].dp1 = NULL;
12290 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12291 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12292 break;
12293
12294 case ssoLIFEMETER:
12295 {
12296 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12297
12298 if(get_bit(deprecated_rules, 12) != 0)
12299 custom_subscreen[0].objects[i].d3=1;
12300 else
12301 custom_subscreen[0].objects[i].d3=0;
12302
12303 break;
12304 }
12305
12306 default:
12307 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12308 break;
12309 }
12310 }
12311
12312 custom_subscreen[0].ss_type=sstACTIVE;
12313 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12314 tempsub = z3_active_ab;
12315
12316 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12317 {
12318 switch(tempsub[i].type)
12319 {
12320 case ssoTEXT:
12321 case ssoTEXTBOX:
12322 case ssoCURRENTITEMTEXT:
12323 case ssoCURRENTITEMCLASSTEXT:
12324 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12325
12326 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12327 custom_subscreen[1].objects[i].dp1 = NULL;
12328 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12329 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12330 break;
12331
12332 case ssoLIFEMETER:
12333 {
12334 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12335
12336 if(get_bit(deprecated_rules, 12) != 0)
12337 custom_subscreen[1].objects[i].d3=1;
12338 else
12339 custom_subscreen[1].objects[i].d3=0;
12340
12341 break;
12342 }
12343
12344 default:
12345 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12346 break;
12347 }
12348 }
12349
12350 custom_subscreen[1].ss_type=sstACTIVE;
12351 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12352 tempsub = z3_passive_a;
12353
12354 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12355 {
12356 switch(tempsub[i].type)
12357 {
12358 case ssoTEXT:
12359 case ssoTEXTBOX:
12360 case ssoCURRENTITEMTEXT:
12361 case ssoCURRENTITEMCLASSTEXT:
12362 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12363
12364 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12365 custom_subscreen[2].objects[i].dp1 = NULL;
12366 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12367 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12368 break;
12369
12370 case ssoLIFEMETER:
12371 {
12372 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12373
12374 if(get_bit(deprecated_rules, 12) != 0)
12375 custom_subscreen[2].objects[i].d3=1;
12376 else
12377 custom_subscreen[2].objects[i].d3=0;
12378
12379 break;
12380 }
12381
12382 default:
12383 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12384 break;
12385 }
12386 }
12387
12388 custom_subscreen[2].ss_type=sstPASSIVE;
12389 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12390 tempsub = z3_passive_ab;
12391
12392 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12393 {
12394 switch(tempsub[i].type)
12395 {
12396 case ssoTEXT:
12397 case ssoTEXTBOX:
12398 case ssoCURRENTITEMTEXT:
12399 case ssoCURRENTITEMCLASSTEXT:
12400 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12401
12402 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12403 custom_subscreen[3].objects[i].dp1 = NULL;
12404 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12405 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12406 break;
12407
12408 case ssoLIFEMETER:
12409 {
12410 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12411
12412 if(get_bit(deprecated_rules, 12) != 0)
12413 custom_subscreen[3].objects[i].d3=1;
12414 else
12415 custom_subscreen[3].objects[i].d3=0;
12416
12417 break;
12418 }
12419
12420 default:
12421 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12422 break;
12423 }
12424 }
12425
12426 custom_subscreen[3].ss_type=sstPASSIVE;
12427 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12428 break;
12429 }
12430 }
12431
12432
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 88 times.
110 for(int32_t i=0; i<4; ++i)
12433 {
12434 88 purge_blank_subscreen_objects(&custom_subscreen[i]);
12435 88 }
12436
12437 22 return 0;
12438 }
12439
12440 extern script_data *ffscripts[NUMSCRIPTFFC];
12441 extern script_data *itemscripts[NUMSCRIPTITEM];
12442 extern script_data *guyscripts[NUMSCRIPTGUYS];
12443 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12444 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12445 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12446 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12447 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12448 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12449 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12450 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12451 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12452 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12453 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12454
12455
12456
12457 99 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12458 {
12459 int32_t dummy;
12460 99 word s_version=0, s_cversion=0, zmeta_version=0;
12461 99 byte numscripts=0;
12462 99 numscripts=numscripts; //to avoid unused variables warnings
12463 int32_t ret;
12464
12465 //section version info
12466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
12467 {
12468 return qe_invalid;
12469 }
12470
12471 99 FFCore.quest_format[vFFScript] = s_version;
12472
12473
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
12474 {
12475 return qe_invalid;
12476 }
12477
12478
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >= 18)
12479 {
12480
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&zmeta_version,f,true))
12481 {
12482 return qe_invalid;
12483 }
12484 24 }
12485
12486 //al_trace("Scripts version %d\n", s_version);
12487 //section size
12488
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
12489 {
12490 return qe_invalid;
12491 }
12492
12493 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12494 99 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12495 99 temp_ffscript_version = s_version;
12496 //miscQdata *the_misc;
12497
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12498 99 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12499
12500 //finally... section data
12501
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12502 {
12503 50688 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12504
12505
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(ret != 0) return qe_invalid;
12506 50688 }
12507
12508 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12509 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12510 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12511 * there was a version bump a week before a change that broke stuff.
12512 */
12513
6/8
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 75 times.
99 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12514 {
12515 75 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12516 75 }
12517
3/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
99 if(s_version < 19 && keepdata)
12518 {
12519 75 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12520 75 }
12521
12522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 1)
12523 {
12524
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12525 {
12526 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12527
12528
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12529 25344 }
12530
12531
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12532 {
12533 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12534
12535
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12536 25344 }
12537
12538
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12539 {
12540 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12541
12542
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12543 25344 }
12544
12545
12546
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12547 {
12548 25344 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12549
12550
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(ret != 0) return qe_invalid;
12551 25344 }
12552
12553
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if(s_version > 16)
12554 {
12555
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12556 {
12557 192 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12558
12559
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(ret != 0) return qe_invalid;
12560 192 }
12561 24 }
12562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 else if(s_version > 13)
12563 {
12564 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12565 {
12566 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12567
12568 if(ret != 0) return qe_invalid;
12569 }
12570
12571 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12572 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12573
12574 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12575 }
12576
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 else if(s_version > 4)
12577 {
12578
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12579 {
12580 300 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12581
12582
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(ret != 0) return qe_invalid;
12583 300 }
12584
12585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12586
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12587
12588
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12589
12590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12591
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12592
12593
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12594
12595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12596
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_F6];
12597
12598
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12599
12600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12601
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12602
12603
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12604 75 }
12605 else
12606 {
12607 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12608 {
12609 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12610
12611 if(ret != 0) return qe_invalid;
12612 }
12613
12614 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12615 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12616
12617 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12618
12619 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12620 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12621
12622 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12623
12624 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12625 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12626
12627 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12628
12629 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12630 delete globalscripts[GLOBAL_SCRIPT_F6];
12631
12632 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12633
12634 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12635 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12636
12637 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12638 }
12639
12640
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if(s_version > 10) //expanded the number of Player scripts to 5.
12641 {
12642
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 24 times.
144 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12643 {
12644 120 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12645
12646
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(ret != 0) return qe_invalid;
12647 120 }
12648 24 }
12649 else
12650 {
12651
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 75 times.
300 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12652 {
12653 225 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12654
12655
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(ret != 0) return qe_invalid;
12656 225 }
12657
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(playerscripts[3] != NULL)
12658
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete playerscripts[3];
12659
12660
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 playerscripts[3] = new script_data();
12661
12662
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(playerscripts[4] != NULL)
12663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 delete playerscripts[4];
12664
12665
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 playerscripts[4] = new script_data();
12666 }
12667
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
99 if(s_version > 8 && s_version < 10)
12668 {
12669
12670 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12671 {
12672 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12673
12674 if(ret != 0) return qe_invalid;
12675 }
12676 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12677 {
12678 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12679
12680 if(ret != 0) return qe_invalid;
12681 }
12682
12683 }
12684
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >= 10)
12685 {
12686
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12687 {
12688 6144 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12689
12690
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(ret != 0) return qe_invalid;
12691 6144 }
12692
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12693 {
12694 6144 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12695
12696
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(ret != 0) return qe_invalid;
12697 6144 }
12698
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12699 {
12700 6144 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12701
12702
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(ret != 0) return qe_invalid;
12703 6144 }
12704
12705 24 }
12706
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >=12)
12707 {
12708
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12709 {
12710 6144 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12711
12712
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 if(ret != 0) return qe_invalid;
12713 6144 }
12714 24 }
12715
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >=15)
12716 {
12717
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 24 times.
12312 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12718 {
12719 12288 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12720
12721
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(ret != 0) return qe_invalid;
12722 12288 }
12723 24 }
12724
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >19)
12725 {
12726 24 word numgenscripts = NUMSCRIPTSGENERIC;
12727
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&numgenscripts,f,true))
12728 {
12729 return qe_invalid;
12730 }
12731
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 24 times.
12312 for(int32_t i = 0; i < numgenscripts; i++)
12732 {
12733 12288 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12734
12735
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(ret != 0) return qe_invalid;
12736 12288 }
12737 24 }
12738
12739 /*
12740 else //Is this trip really necessary?
12741 {
12742 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12743 {
12744
12745 ewpnscripts[i] = NULL;
12746 }
12747 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12748 {
12749 dmapscripts[i] = NULL;
12750 }
12751 }
12752 */
12753
12754 99 }
12755
12756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 2)
12757 {
12758 int32_t bufsize;
12759 99 p_igetl(&bufsize, f, true);
12760 99 char * buf = new char[bufsize+1];
12761 99 pfread(buf, bufsize, f, true);
12762 99 buf[bufsize]=0;
12763
12764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
12765
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 zScript = string(buf);
12766
12767
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 delete[] buf;
12768 word numffcbindings;
12769 99 p_igetw(&numffcbindings, f, true);
12770
12771
2/2
✓ Branch 0 taken 1442 times.
✓ Branch 1 taken 99 times.
1541 for(int32_t i=0; i<numffcbindings; i++)
12772 {
12773 word id;
12774 1442 p_igetw(&id, f, true);
12775 1442 p_igetl(&bufsize, f, true);
12776 1442 buf = new char[bufsize+1];
12777 1442 pfread(buf, bufsize, f, true);
12778 1442 buf[bufsize]=0;
12779
12780 //fix for buggy older saved quests -DD
12781
2/4
✓ Branch 0 taken 1442 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1442 times.
1442 if(keepdata && id < NUMSCRIPTFFC-1)
12782 1442 ffcmap[id].scriptname = buf;
12783
12784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 delete[] buf;
12785 1442 }
12786
12787 word numglobalbindings;
12788 99 p_igetw(&numglobalbindings, f, true);
12789
12790
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 99 times.
501 for(int32_t i=0; i<numglobalbindings; i++)
12791 {
12792 word id;
12793 402 p_igetw(&id, f, true);
12794 402 p_igetl(&bufsize, f, true);
12795 402 buf = new char[bufsize+1];
12796 402 pfread(buf, bufsize, f, true);
12797 402 buf[bufsize]=0;
12798
12799 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12800 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12801 // Ignore these. -DD
12802
4/6
✓ Branch 0 taken 402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 243 times.
402 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12803 {
12804 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12805
1/2
✓ Branch 0 taken 243 times.
✗ Branch 1 not taken.
243 if(strcmp(buf,"~Continue") == 0)
12806 {
12807 globalmap[id].scriptname = "";
12808
12809 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12810 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12811 }
12812 else
12813 {
12814 243 globalmap[id].scriptname = buf;
12815 }
12816 243 }
12817
12818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 delete[] buf;
12819 402 }
12820
12821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version > 3)
12822 {
12823 word numitembindings;
12824 99 p_igetw(&numitembindings, f, true);
12825
12826
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 99 times.
197 for(int32_t i=0; i<numitembindings; i++)
12827 {
12828 word id;
12829 98 p_igetw(&id, f, true);
12830 98 p_igetl(&bufsize, f, true);
12831 98 buf = new char[bufsize+1];
12832 98 pfread(buf, bufsize, f, true);
12833 98 buf[bufsize]=0;
12834
12835 //fix this too
12836
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if(keepdata && id <NUMSCRIPTITEM-1)
12837 98 itemmap[id].scriptname = buf;
12838
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12840 98 }
12841 99 }
12842 //(v9+)
12843
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version > 8)
12844 {
12845 //npc scripts
12846 word numnpcbindings;
12847 24 p_igetw(&numnpcbindings, f, true);
12848
12849
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
36 for(int32_t i=0; i<numnpcbindings; i++)
12850 {
12851 word id;
12852 12 p_igetw(&id, f, true);
12853 12 p_igetl(&bufsize, f, true);
12854 12 buf = new char[bufsize+1];
12855 12 pfread(buf, bufsize, f, true);
12856 12 buf[bufsize]=0;
12857
12858 //fix this too
12859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12860 12 npcmap[id].scriptname = buf;
12861
12862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12863 12 }
12864 //lweapon
12865 word numlwpnbindings;
12866 24 p_igetw(&numlwpnbindings, f, true);
12867
12868
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 24 times.
66 for(int32_t i=0; i<numlwpnbindings; i++)
12869 {
12870 word id;
12871 42 p_igetw(&id, f, true);
12872 42 p_igetl(&bufsize, f, true);
12873 42 buf = new char[bufsize+1];
12874 42 pfread(buf, bufsize, f, true);
12875 42 buf[bufsize]=0;
12876
12877 //fix this too
12878
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12879 42 lwpnmap[id].scriptname = buf;
12880
12881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12882 42 }
12883 //eweapon
12884 word numewpnbindings;
12885 24 p_igetw(&numewpnbindings, f, true);
12886
12887
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 24 times.
87 for(int32_t i=0; i<numewpnbindings; i++)
12888 {
12889 word id;
12890 63 p_igetw(&id, f, true);
12891 63 p_igetl(&bufsize, f, true);
12892 63 buf = new char[bufsize+1];
12893 63 pfread(buf, bufsize, f, true);
12894 63 buf[bufsize]=0;
12895
12896 //fix this too
12897
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12898 63 ewpnmap[id].scriptname = buf;
12899
12900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12901 63 }
12902 //hero
12903 word numherobindings;
12904 24 p_igetw(&numherobindings, f, true);
12905
12906
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 24 times.
28 for(int32_t i=0; i<numherobindings; i++)
12907 {
12908 word id;
12909 4 p_igetw(&id, f, true);
12910 4 p_igetl(&bufsize, f, true);
12911 4 buf = new char[bufsize+1];
12912 4 pfread(buf, bufsize, f, true);
12913 4 buf[bufsize]=0;
12914
12915 //fix this too
12916
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12917 4 playermap[id].scriptname = buf;
12918
12919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12920 4 }
12921 //dmaps
12922 word numdmapbindings;
12923 24 p_igetw(&numdmapbindings, f, true);
12924
12925
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 for(int32_t i=0; i<numdmapbindings; i++)
12926 {
12927 word id;
12928 14 p_igetw(&id, f, true);
12929 14 p_igetl(&bufsize, f, true);
12930 14 buf = new char[bufsize+1];
12931 14 pfread(buf, bufsize, f, true);
12932 14 buf[bufsize]=0;
12933
12934 //fix this too
12935
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12936 14 dmapmap[id].scriptname = buf;
12937
12938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12939 14 }
12940 //screen
12941 word numscreenbindings;
12942 24 p_igetw(&numscreenbindings, f, true);
12943
12944
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 24 times.
35 for(int32_t i=0; i<numscreenbindings; i++)
12945 {
12946 word id;
12947 11 p_igetw(&id, f, true);
12948 11 p_igetl(&bufsize, f, true);
12949 11 buf = new char[bufsize+1];
12950 11 pfread(buf, bufsize, f, true);
12951 11 buf[bufsize]=0;
12952
12953 //fix this too
12954
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12955 11 screenmap[id].scriptname = buf;
12956
12957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12958 11 }
12959 24 }
12960
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version > 11)
12961 {
12962 word numspritebindings;
12963 24 p_igetw(&numspritebindings, f, true);
12964
12965
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 24 times.
34 for(int32_t i=0; i<numspritebindings; i++)
12966 {
12967 word id;
12968 10 p_igetw(&id, f, true);
12969 10 p_igetl(&bufsize, f, true);
12970 10 buf = new char[bufsize+1];
12971 10 pfread(buf, bufsize, f, true);
12972 10 buf[bufsize]=0;
12973
12974 //fix this too
12975
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
12976 10 itemspritemap[id].scriptname = buf;
12977
12978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12979 10 }
12980 24 }
12981
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version >= 15)
12982 {
12983 word numcombobindings;
12984 24 p_igetw(&numcombobindings, f, true);
12985
12986
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 for(int32_t i=0; i<numcombobindings; i++)
12987 {
12988 word id;
12989 24 p_igetw(&id, f, true);
12990 24 p_igetl(&bufsize, f, true);
12991 24 buf = new char[bufsize+1];
12992 24 pfread(buf, bufsize, f, true);
12993 24 buf[bufsize]=0;
12994
12995 //fix this too
12996
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12997 24 comboscriptmap[id].scriptname = buf;
12998
12999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
13000 24 }
13001 24 }
13002
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 24 times.
99 if(s_version > 19)
13003 {
13004 word numgenericbindings;
13005 24 p_igetw(&numgenericbindings, f, true);
13006
13007
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 for(int32_t i=0; i<numgenericbindings; i++)
13008 {
13009 word id;
13010 14 p_igetw(&id, f, true);
13011 14 p_igetl(&bufsize, f, true);
13012 14 buf = new char[bufsize+1];
13013 14 pfread(buf, bufsize, f, true);
13014 14 buf[bufsize]=0;
13015
13016 //fix this too
13017
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13018 14 genericmap[id].scriptname = buf;
13019
13020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
13021 14 }
13022 24 }
13023 99 }
13024
13025 99 return 0;
13026 99 }
13027
13028 108 void reset_scripts()
13029 {
13030 //OK, who spaced this? ;)
13031
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13032 {
13033
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55296 times.
55296 if(ffscripts[i]!=NULL) delete ffscripts[i];
13034 55296 }
13035
13036
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13037 {
13038
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(itemscripts[i]!=NULL) delete itemscripts[i];
13039 27648 }
13040
13041
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13042 {
13043
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(guyscripts[i]!=NULL) delete guyscripts[i];
13044 27648 }
13045
13046
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13047 {
13048
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13049 27648 }
13050
13051
13052
13053
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13054 {
13055
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(screenscripts[i]!=NULL) delete screenscripts[i];
13056 27648 }
13057
13058
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13059 {
13060
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 if(globalscripts[i]!=NULL) delete globalscripts[i];
13061 864 }
13062
13063
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 108 times.
648 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13064 {
13065
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 540 times.
540 if(playerscripts[i]!=NULL) delete playerscripts[i];
13066 540 }
13067
13068
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13069 {
13070
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13071 27648 }
13072
13073
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13074 {
13075
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13076 27648 }
13077
13078
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13079 {
13080
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13081 27648 }
13082
13083
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13084 {
13085
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27648 times.
27648 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13086 27648 }
13087
13088
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13089 {
13090
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55296 times.
55296 if(comboscripts[i]!=NULL) delete comboscripts[i];
13091 55296 }
13092
13093 108 next_script_data_debug_id = 0;
13094
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13095 {
13096
3/4
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 38400 times.
✓ Branch 2 taken 38400 times.
✗ Branch 3 not taken.
55296 if(genericscripts[i]!=NULL) delete genericscripts[i];
13097
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 genericscripts[i] = new script_data();
13098 55296 }
13099
13100
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13101 {
13102
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 ffscripts[i] = new script_data();
13103 55296 }
13104
13105
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13106 {
13107
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 itemscripts[i] = new script_data();
13108 27648 }
13109
13110
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13111 {
13112
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 guyscripts[i] = new script_data();
13113 27648 }
13114
13115
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13116 {
13117
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 wpnscripts[i] = new script_data();
13118 27648 }
13119
13120
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13121 {
13122
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 screenscripts[i] = new script_data();
13123 27648 }
13124
13125
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 108 times.
972 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13126 {
13127
1/2
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
864 globalscripts[i] = new script_data();
13128 864 }
13129
13130
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 108 times.
648 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13131 {
13132
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 playerscripts[i] = new script_data();
13133 540 }
13134
13135
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13136 {
13137
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 lwpnscripts[i] = new script_data();
13138 27648 }
13139
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13140 {
13141
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 ewpnscripts[i] = new script_data();
13142 27648 }
13143
13144
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13145 {
13146
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 dmapscripts[i] = new script_data();
13147 27648 }
13148
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 108 times.
27756 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13149 {
13150
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 itemspritescripts[i] = new script_data();
13151 27648 }
13152
2/2
✓ Branch 0 taken 55296 times.
✓ Branch 1 taken 108 times.
55404 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13153 {
13154
1/2
✓ Branch 0 taken 55296 times.
✗ Branch 1 not taken.
55296 comboscripts[i] = new script_data();
13155 55296 }
13156 108 }
13157
13158 extern script_command command_list[];
13159 202053 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13160 {
13161 //Please also update loadquest() when modifying this method -DD
13162 202053 char b33[34] = {0};
13163 202053 b33[33] = 0;
13164 202053 ffscript temp_script;
13165 202053 int32_t num_commands=1000;
13166
13167
1/2
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
202053 if(s_version>=2)
13168 {
13169
2/4
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202053 times.
✗ Branch 3 not taken.
202053 if(!p_igetl(&num_commands,f,true))
13170 {
13171 return qe_invalid;
13172 }
13173 202053 }
13174
13175
1/2
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
202053 if(keepdata)
13176 {
13177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202053 times.
202053 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202053 times.
202053 delete (*script);
13179
2/4
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202053 times.
✗ Branch 3 not taken.
202053 (*script) = new script_data(num_commands);
13180 202053 }
13181
2/2
✓ Branch 0 taken 86328 times.
✓ Branch 1 taken 115725 times.
202053 if(s_version >= 16)
13182 {
13183
1/2
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
86328 zasm_meta temp_meta;
13184
13185
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13186 {
13187 return qe_invalid;
13188 }
13189
13190
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.meta_v),f,true))
13191 {
13192 return qe_invalid;
13193 }
13194
13195
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13196 {
13197 return qe_invalid;
13198 }
13199
13200
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_getc(&(temp_meta.script_type),f,true))
13201 {
13202 return qe_invalid;
13203 }
13204
13205
2/2
✓ Branch 0 taken 690624 times.
✓ Branch 1 taken 86328 times.
776952 for(int32_t q = 0; q < 8; ++q)
13206 {
13207
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 633072 times.
690624 if(zmeta_version < 3)
13208 {
13209
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13210 {
13211
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13212 {
13213 return qe_invalid;
13214 }
13215 1899216 }
13216
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13217 57552 }
13218 else
13219 {
13220
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13221 {
13222 return qe_invalid;
13223 }
13224 }
13225 690624 }
13226
13227
2/2
✓ Branch 0 taken 86328 times.
✓ Branch 1 taken 690624 times.
776952 for(int32_t q = 0; q < 8; ++q)
13228 {
13229
2/4
✓ Branch 0 taken 690624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 690624 times.
✗ Branch 3 not taken.
690624 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13230 {
13231 return qe_invalid;
13232 }
13233 690624 }
13234
13235
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_getc(&(temp_meta.flags),f,true))
13236 {
13237 return qe_invalid;
13238 }
13239
13240
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13241 {
13242 return qe_invalid;
13243 }
13244
13245
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13246 {
13247 return qe_invalid;
13248 }
13249
13250
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13251 {
13252 return qe_invalid;
13253 }
13254
13255
2/4
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86328 times.
✗ Branch 3 not taken.
86328 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13256 {
13257 return qe_invalid;
13258 }
13259
13260
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 79134 times.
86328 if(zmeta_version == 2)
13261 {
13262
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13263 {
13264
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13265 {
13266 return qe_invalid;
13267 }
13268 237402 }
13269
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13270
13271
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13272 {
13273
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13274 {
13275 return qe_invalid;
13276 }
13277 237402 }
13278
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13279 7194 }
13280
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 else if(zmeta_version > 2)
13281 {
13282
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getcstr(&temp_meta.script_name,f,true))
13283 return qe_invalid;
13284
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getcstr(&temp_meta.author,f,true))
13285 return qe_invalid;
13286 79134 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13287
2/2
✓ Branch 0 taken 791340 times.
✓ Branch 1 taken 79134 times.
870474 for(auto q = 0; q < num_meta_attrib; ++q)
13288 {
13289
2/4
✓ Branch 0 taken 791340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 791340 times.
✗ Branch 3 not taken.
791340 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13290 return qe_invalid;
13291
2/4
✓ Branch 0 taken 791340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 791340 times.
✗ Branch 3 not taken.
791340 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13292 return qe_invalid;
13293 791340 }
13294
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(auto q = 0; q < 8; ++q)
13295 {
13296
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13297 return qe_invalid;
13298
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13299 return qe_invalid;
13300 633072 }
13301
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(auto q = 0; q < 8; ++q)
13302 {
13303
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13304 return qe_invalid;
13305
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13306 return qe_invalid;
13307 633072 }
13308
2/2
✓ Branch 0 taken 1266144 times.
✓ Branch 1 taken 79134 times.
1345278 for(auto q = 0; q < 16; ++q)
13309 {
13310
2/4
✓ Branch 0 taken 1266144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1266144 times.
✗ Branch 3 not taken.
1266144 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13311 return qe_invalid;
13312
2/4
✓ Branch 0 taken 1266144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1266144 times.
✗ Branch 3 not taken.
1266144 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13313 return qe_invalid;
13314 1266144 }
13315 79134 }
13316
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 7194 times.
86328 if(zmeta_version > 3)
13317 {
13318
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(auto q = 0; q < 8; ++q)
13319 {
13320
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getcstr(&temp_meta.initd[q],f,true))
13321 return qe_invalid;
13322
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13323 return qe_invalid;
13324 633072 }
13325
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(auto q = 0; q < 8; ++q)
13326 {
13327
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getc(&temp_meta.initd_type[q],f,true))
13328 return qe_invalid;
13329 633072 }
13330 79134 }
13331 else
13332 {
13333
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13334 {
13335
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13336 57552 }
13337 }
13338
13339
1/2
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
86328 if(keepdata)
13340
1/2
✓ Branch 0 taken 86328 times.
✗ Branch 1 not taken.
86328 (*script)->meta = temp_meta;
13341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86328 times.
86328 }
13342
13343
1/2
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
202053 temp_script.clear();
13344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21324751 times.
21324751 for(int32_t j=0; j<num_commands; j++)
13345 {
13346
2/4
✓ Branch 0 taken 21324751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21324751 times.
✗ Branch 3 not taken.
21324751 if(!p_igetw(&(temp_script.command),f,true))
13347 {
13348 return qe_invalid;
13349 }
13350
13351
2/2
✓ Branch 0 taken 21122698 times.
✓ Branch 1 taken 202053 times.
21324751 if(temp_script.command == 0xFFFF)
13352 {
13353
1/2
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
202053 if(keepdata)
13354
1/2
✓ Branch 0 taken 202053 times.
✗ Branch 1 not taken.
202053 (*script)->zasm[j].clear();
13355 202053 break;
13356 }
13357 else
13358 {
13359
2/4
✓ Branch 0 taken 21122698 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21122698 times.
✗ Branch 3 not taken.
21122698 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13360 {
13361 return qe_invalid;
13362 }
13363
13364
2/4
✓ Branch 0 taken 21122698 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21122698 times.
✗ Branch 3 not taken.
21122698 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13365 {
13366 return qe_invalid;
13367 }
13368
13369
2/2
✓ Branch 0 taken 451729 times.
✓ Branch 1 taken 20670969 times.
21122698 if(s_version >= 21)
13370 {
13371 451729 uint32_t sz = 0;
13372
2/4
✓ Branch 0 taken 451729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451729 times.
✗ Branch 3 not taken.
451729 if(!p_igetl(&sz,f,keepdata))
13373 {
13374 return qe_invalid;
13375 }
13376
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450207 times.
451729 if(sz) //string found
13377 {
13378
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13379 char dummy;
13380
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13381 {
13382
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13383 {
13384 return qe_invalid;
13385 }
13386
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13387 115152 }
13388 1522 }
13389
2/4
✓ Branch 0 taken 451729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451729 times.
✗ Branch 3 not taken.
451729 if(!p_igetl(&sz,f,keepdata))
13390 {
13391 return qe_invalid;
13392 }
13393
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451639 times.
451729 if(sz) //vector found
13394 {
13395
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13396 int32_t dummy;
13397
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13398 {
13399
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13400 {
13401 return qe_invalid;
13402 }
13403
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13404 1311 }
13405 90 }
13406 451729 }
13407
13408
1/2
✓ Branch 0 taken 21122698 times.
✗ Branch 1 not taken.
21122698 if(keepdata)
13409 {
13410
1/2
✓ Branch 0 taken 21122698 times.
✗ Branch 1 not taken.
21122698 temp_script.give((*script)->zasm[j]);
13411 21122698 }
13412 }
13413
1/2
✓ Branch 0 taken 21122698 times.
✗ Branch 1 not taken.
21122698 temp_script.clear();
13414 21122698 }
13415
13416 202053 return 0;
13417 202053 }
13418
13419 extern SAMPLE customsfxdata[WAV_COUNT];
13420 extern uint8_t customsfxflag[WAV_COUNT>>3];
13421 extern int32_t sfxdat;
13422 extern DATAFILE *sfxdata;
13423 const char *old_sfx_string[Z35] =
13424 {
13425 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13426 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13427 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13428 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13429 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13430 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13431 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13432 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13433 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13434 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13435 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13436 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13437 };
13438 char *sfx_string[WAV_COUNT];
13439
13440 99 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13441 {
13442 //these are here to bypass compiler warnings about unused arguments
13443 99 Header=Header;
13444
13445 int32_t dummy;
13446 99 word s_version=0, s_cversion=0;
13447 //int32_t ret;
13448 SAMPLE temp_sample;
13449 99 temp_sample.loop_start=0;
13450 99 temp_sample.loop_end=0;
13451 99 temp_sample.param=0;
13452
13453 //section version info
13454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
13455 {
13456 return qe_invalid;
13457 }
13458
13459 99 FFCore.quest_format[vSFX] = s_version;
13460
13461 //al_trace("SFX version %d\n", s_version);
13462
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
13463 {
13464 return qe_invalid;
13465 }
13466
13467 //section size
13468
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
13469 {
13470 return qe_invalid;
13471 }
13472
13473 /* HIGHLY UNORTHODOX UPDATING THING, by L
13474 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13475 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13476 * changing from 1 to 2.
13477 */
13478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(s_version < 2 && keepdata)
13479 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13480
13481 /* End highly unorthodox updating thing */
13482
13483 99 int32_t wavcount = WAV_COUNT;
13484
13485
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version < 6)
13486 wavcount = 128;
13487
13488 uint8_t tempflag[WAV_COUNT>>3];
13489
13490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version < 4)
13491 {
13492 memset(tempflag, 0xFF, WAV_COUNT>>3);
13493 }
13494 else
13495 {
13496
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version < 6)
13497 memset(tempflag, 0, WAV_COUNT>>3);
13498
13499
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 99 times.
3267 for(int32_t i=0; i<(wavcount>>3); i++)
13500 {
13501 3168 p_getc(&tempflag[i], f, true);
13502 3168 }
13503
13504 }
13505
13506
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(s_version>4)
13507 {
13508
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<WAV_COUNT; i++)
13509 {
13510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25245 times.
25245 if(keepdata)
13511 {
13512 25245 sprintf(sfx_string[i],"s%03d",i);
13513
13514
2/2
✓ Branch 0 taken 19305 times.
✓ Branch 1 taken 5940 times.
25245 if((i<Z35))
13515 5940 strcpy(sfx_string[i], old_sfx_string[i-1]);
13516 25245 }
13517
13518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25245 times.
25245 if(i>=wavcount)
13519 continue;
13520
2/2
✓ Branch 0 taken 2146 times.
✓ Branch 1 taken 23099 times.
25245 if(get_bit(tempflag, i-1))
13521 {
13522 char tempname[36];
13523
13524
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!pfread(tempname, 36, f, keepdata))
13525 {
13526 return qe_invalid;
13527 }
13528
13529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2146 times.
2146 if(keepdata)
13530 {
13531 2146 strcpy(sfx_string[i], tempname);
13532 2146 sfx_string[i][35] = 0; //Force NULL Termination
13533 2146 }
13534 2146 }
13535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23099 times.
23099 else if(keepdata)
13536 {
13537 23099 sprintf(sfx_string[i],"s%03d",i);
13538
13539
2/2
✓ Branch 0 taken 18641 times.
✓ Branch 1 taken 4458 times.
23099 if(i<Z35)
13540 4458 strcpy(sfx_string[i], old_sfx_string[i-1]);
13541 23099 sfx_string[i][35] = 0; //Force NULL Termination
13542 23099 }
13543 25245 }
13544 99 }
13545 else
13546 {
13547 if(keepdata)
13548 {
13549 for(int32_t i=1; i<WAV_COUNT; i++)
13550 {
13551 sprintf(sfx_string[i],"s%03d",i);
13552
13553 if(i<Z35)
13554 strcpy(sfx_string[i], old_sfx_string[i-1]);
13555 }
13556 }
13557 }
13558
13559 //finally... section data
13560
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<wavcount; i++)
13561 {
13562
2/2
✓ Branch 0 taken 2146 times.
✓ Branch 1 taken 23099 times.
25245 if(get_bit(tempflag, i-1))
13563 {
13564
13565
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&dummy,f,true))
13566 {
13567 return qe_invalid;
13568 }
13569
13570 2146 (temp_sample.bits) = dummy;
13571
13572
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&dummy,f,true))
13573 {
13574 return qe_invalid;
13575 }
13576
13577 2146 (temp_sample.stereo) = dummy;
13578
13579
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&dummy,f,keepdata))
13580 {
13581 return qe_invalid;
13582 }
13583
13584 2146 (temp_sample.freq) = dummy;
13585
13586
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&dummy,f,keepdata))
13587 {
13588 return qe_invalid;
13589 }
13590
13591 2146 (temp_sample.priority) = dummy;
13592
13593
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&(temp_sample.len),f,true))
13594 {
13595 return qe_invalid;
13596 }
13597
13598
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13599 {
13600 return qe_invalid;
13601 }
13602
13603
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13604 {
13605 return qe_invalid;
13606 }
13607
13608
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(!p_igetl(&(temp_sample.param),f,keepdata))
13609 {
13610 return qe_invalid;
13611 }
13612
13613 // al_trace("F%i: L%i\n",i,temp_sample.len);
13614 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13615 2146 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13616 2146 temp_sample.data = calloc(len,1);
13617
13618
1/2
✓ Branch 0 taken 2146 times.
✗ Branch 1 not taken.
2146 if(s_version < 3)
13619 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13620
13621 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2146 times.
2146 if(s_version < 2)
13623 {
13624 if(!pfread(temp_sample.data, len,f,keepdata))
13625 {
13626 return qe_invalid;
13627 }
13628 }
13629 else
13630 {
13631 //re-endianfy the data
13632 2146 int32_t wordstoread = len / sizeof(word);
13633
13634
2/2
✓ Branch 0 taken 66725784 times.
✓ Branch 1 taken 2146 times.
66727930 for(int32_t j=0; j<wordstoread; j++)
13635 {
13636 word temp;
13637
13638
1/2
✓ Branch 0 taken 66725784 times.
✗ Branch 1 not taken.
66725784 if(!p_igetw(&temp, f, keepdata))
13639 {
13640 return qe_invalid;
13641 }
13642
13643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66725784 times.
66725784 if(keepdata)
13644 66725784 ((word *)temp_sample.data)[j] = temp;
13645 66725784 }
13646 }
13647 2146 }
13648
2/2
✓ Branch 0 taken 4458 times.
✓ Branch 1 taken 18641 times.
23099 else if(i < Z35)
13649 {
13650 4458 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13651 4458 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13652 4458 set_bit(tempflag, i-1, 1);
13653 4458 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13654 4458 temp_sample.data = calloc(len,1);
13655 4458 memcpy(temp_sample.data, datsamp->data, len);
13656 4458 }
13657 18641 else continue;
13658
13659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
6604 if(keepdata)
13660 {
13661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
6604 if(customsfxdata[i].data!=NULL)
13662 {
13663 // delete [] customsfxdata[i].data;
13664 6604 free(customsfxdata[i].data);
13665 6604 }
13666
13667 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13668 6604 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13669 6604 customsfxdata[i].data = calloc(len2,1);
13670 6604 customsfxdata[i].bits = temp_sample.bits;
13671 6604 customsfxdata[i].stereo = temp_sample.stereo;
13672 6604 customsfxdata[i].freq = temp_sample.freq;
13673 6604 customsfxdata[i].priority = temp_sample.priority;
13674 6604 customsfxdata[i].len = temp_sample.len;
13675 6604 customsfxdata[i].loop_start = temp_sample.loop_start;
13676 6604 customsfxdata[i].loop_end = temp_sample.loop_end;
13677 6604 customsfxdata[i].param = temp_sample.param;
13678 6604 int32_t cpylen = len2;
13679
13680
1/2
✓ Branch 0 taken 6604 times.
✗ Branch 1 not taken.
6604 if(s_version<3)
13681 {
13682 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13683 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13684 }
13685
13686 6604 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13687 6604 }
13688
13689 6604 free(temp_sample.data);
13690 6604 }
13691
13692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
13693 99 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13694
13695 99 sfxdat=0;
13696 99 return 0;
13697 99 }
13698
13699 108 void setupsfx()
13700 {
13701
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=1; i<WAV_COUNT; i++)
13702 {
13703 27540 sprintf(sfx_string[i],"s%03d",i);
13704
13705
2/2
✓ Branch 0 taken 21060 times.
✓ Branch 1 taken 6480 times.
27540 if(i<Z35)
13706 {
13707 6480 strcpy(sfx_string[i], old_sfx_string[i-1]);
13708 6480 }
13709
13710 27540 memset(customsfxflag, 0, WAV_COUNT>>3);
13711
13712 27540 int32_t j=i;
13713
13714
2/2
✓ Branch 0 taken 6588 times.
✓ Branch 1 taken 20952 times.
27540 if(i>Z35)
13715 {
13716 20952 i=Z35;
13717 20952 }
13718
13719 27540 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13720
13721
2/2
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 19125 times.
27540 if(customsfxdata[j].data!=NULL)
13722 {
13723 // delete [] customsfxdata[j].data;
13724 19125 free(customsfxdata[j].data);
13725 19125 }
13726
13727 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13728 27540 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13729 27540 customsfxdata[j].bits = temp_sample->bits;
13730 27540 customsfxdata[j].stereo = temp_sample->stereo;
13731 27540 customsfxdata[j].freq = temp_sample->freq;
13732 27540 customsfxdata[j].priority = temp_sample->priority;
13733 27540 customsfxdata[j].len = temp_sample->len;
13734 27540 customsfxdata[j].loop_start = temp_sample->loop_start;
13735 27540 customsfxdata[j].loop_end = temp_sample->loop_end;
13736 27540 customsfxdata[j].param = temp_sample->param;
13737 27540 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13738 27540 i=j;
13739 27540 }
13740 108 }
13741
13742 extern char *guy_string[eMAXGUYS];
13743 extern const char *old_guy_string[OLDMAXGUYS];
13744
13745 108 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13746 {
13747 dword dummy;
13748 word guy_cversion;
13749 108 word guyversion=0;
13750
13751
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version >= 0x193)
13752 {
13753 //section version info
13754
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&guyversion,f,true))
13755 {
13756 return qe_invalid;
13757 }
13758
13759 104 FFCore.quest_format[vGuys] = guyversion;
13760
13761 //al_trace("Guys version %d\n", guyversion);
13762
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&guy_cversion,f,true))
13763 {
13764 return qe_invalid;
13765 }
13766 104 al_trace("Guy CVersion is: %d\n", guy_cversion);
13767 //section size
13768
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
13769 {
13770 return qe_invalid;
13771 }
13772 104 }
13773
13774
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(guyversion > 3)
13775 {
13776
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
13777 {
13778 char tempname[64];
13779
13780 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13781 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13782
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50688 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13783 {
13784 memset(tempname, 0, sizeof(char)*64);
13785 sprintf(tempname, "e%03d", i);
13786 strcpy(guy_string[i], tempname);
13787
13788 continue;
13789 }
13790
13791
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!pfread(tempname, 64, f, keepdata))
13792 {
13793 return qe_invalid;
13794 }
13795
13796 // Don't retain names of uneditable enemy entries!
13797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(keepdata)
13798 {
13799 // for version upgrade to 2.5
13800
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50688 if(guyversion < 23 && i >= 177)
13801 {
13802 // some of the older builds have names such as 'zz123',
13803 // (this order gets messed up with some eXXX and some zzXXX)
13804 // so let's update to the newer naming convection. -Gleeok
13805 char tmpbuf[64];
13806 memset(tmpbuf, 0, sizeof(char)*64);
13807 sprintf(tmpbuf, "zz%03d", i);
13808
13809 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13810 {
13811 memset(tempname, 0, sizeof(char)*64);
13812 sprintf(tempname, "e%03d", i);
13813 }
13814 }
13815
13816
6/6
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 33165 times.
✓ Branch 2 taken 16632 times.
✓ Branch 3 taken 891 times.
✓ Branch 4 taken 13737 times.
✓ Branch 5 taken 2895 times.
50688 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13817 {
13818 47793 strcpy(guy_string[i], tempname);
13819 47793 }
13820 else
13821 {
13822 2895 strcpy(guy_string[i],old_guy_string[i]);
13823 }
13824 50688 }
13825 50688 }
13826 99 }
13827 else
13828 {
13829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13830 {
13831
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13832 {
13833 4608 sprintf(guy_string[i],"zz%03d",i);
13834 4608 }
13835
13836
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13837 {
13838 1593 strcpy(guy_string[i],old_guy_string[i]);
13839 1593 }
13840 9 }
13841 }
13842
13843
13844 //finally... section data
13845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
13846 {
13847 108 init_guys(guyversion); //using default data for now...
13848
13849 // Goriya guy fix
13850
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13851 {
13852
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13853 {
13854 5 guysbuf[gGORIYA].tile=130;
13855 5 guysbuf[gGORIYA].e_tile=130;
13856 5 }
13857 9 }
13858 108 }
13859
13860
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version < 0x193)
13861 {
13862
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13863 {
13864 guysbuf[eDODONGO].cset=14;
13865 guysbuf[eDODONGO].bosspal=spDIG;
13866 }
13867 4 }
13868 // Not sure when this first changed, but it's necessary for 2.10, at least
13869 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13870 //2.10 Fixes
13871
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13872 {
13873 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13874 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13875 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13876 9 guysbuf[eCENT1].misc3 = 1;
13877 9 guysbuf[eCENT2].misc3 = 1;
13878 9 }
13879
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13880 {
13881 108 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13882 108 }
13883
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(Header->zelda_version <= 0x210)
13884 {
13885 9 guysbuf[eGLEEOK1F].misc6 = 16;
13886 9 guysbuf[eGLEEOK2F].misc6 = 16;
13887 9 guysbuf[eGLEEOK3F].misc6 = 16;
13888 9 guysbuf[eGLEEOK4F].misc6 = 16;
13889
13890 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13891 9 guysbuf[eBATROBE].misc4 = 1;
13892 //guysbuf[eSUMMONER].misc4 = 1;
13893 9 guysbuf[eWWIZ].misc4 = 1;
13894 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13895 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13896 9 }
13897
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version == 0x190)
13898 {
13899 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13900 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13901 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13902 4 }
13903
13904 // The versions here may not be correct
13905 // zelda_version>=0x211 handled at guyversion<24
13906
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version <= 0x190)
13907 {
13908 4 guysbuf[eCENT1].misc3 = 0;
13909 4 guysbuf[eCENT2].misc3 = 0;
13910 4 guysbuf[eMOLDORM].misc2 = 0;
13911 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13912 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13913 4 }
13914
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 else if(Header->zelda_version <= 0x210)
13915 {
13916 5 guysbuf[eCENT1].misc3 = 1;
13917 5 guysbuf[eCENT2].misc3 = 1;
13918 5 guysbuf[eMOLDORM].misc2 = 0;
13919 5 }
13920
13921
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13922 {
13923 9 guysbuf[eKEESE1].misc16 = 120;
13924 9 guysbuf[eKEESE2].misc16 = 120;
13925 9 guysbuf[eKEESE3].misc16 = 120;
13926 9 guysbuf[eKEESETRIB].misc16 = 120;
13927 9 guysbuf[eKEESE1].misc17 = 16;
13928 9 guysbuf[eKEESE2].misc17 = 16;
13929 9 guysbuf[eKEESE3].misc17 = 16;
13930 9 guysbuf[eKEESETRIB].misc17 = 16;
13931
13932 9 guysbuf[ePEAHAT].misc16 = 80;
13933 9 guysbuf[ePEAHAT].misc17 = 16;
13934
13935 9 guysbuf[eGHINI2].misc16 = 120;
13936 9 guysbuf[eGHINI2].misc17 = 10;
13937
13938 9 }
13939
13940
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(guyversion<=2)
13941 {
13942 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13943 }
13944
13945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(guyversion > 3)
13946 {
13947 guydata tempguy;
13948
13949
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
13950 {
13951
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50688 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13952 {
13953 if(i >= OLDBETAMAXGUYS)
13954 {
13955 memset(&guysbuf[i], 0, sizeof(guydata));
13956 continue;
13957 }
13958 }
13959
13960 50688 memset(&tempguy, 0, sizeof(guydata));
13961
13962
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.flags),f,keepdata))
13963 {
13964 return qe_invalid;
13965 }
13966
13967
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13968 {
13969 return qe_invalid;
13970 }
13971
13972
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion >= 36 ) //expanded tiles
13973 {
13974
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.tile),f,keepdata))
13975 {
13976 return qe_invalid;
13977 }
13978 12288 }
13979 else
13980 {
13981
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.tile),f,keepdata))
13982 {
13983 return qe_invalid;
13984 }
13985 }
13986
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.width),f,keepdata))
13987 {
13988 return qe_invalid;
13989 }
13990
13991
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.height),f,keepdata))
13992 {
13993 return qe_invalid;
13994 }
13995
13996
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion >= 36 ) //expanded tiles
13997 {
13998
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13999 {
14000 return qe_invalid;
14001 }
14002 12288 }
14003 else
14004 {
14005
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14006 {
14007 return qe_invalid;
14008 }
14009 }
14010
14011
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.s_width),f,keepdata))
14012 {
14013 return qe_invalid;
14014 }
14015
14016
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.s_height),f,keepdata))
14017 {
14018 return qe_invalid;
14019 }
14020
14021
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion >= 36 ) //expanded tiles
14022 {
14023
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14024 {
14025 return qe_invalid;
14026 }
14027 12288 }
14028 else
14029 {
14030
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14031 {
14032 return qe_invalid;
14033 }
14034 }
14035
14036
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.e_width),f,keepdata))
14037 {
14038 return qe_invalid;
14039 }
14040
14041
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.e_height),f,keepdata))
14042 {
14043 return qe_invalid;
14044 }
14045
14046
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.hp),f,keepdata))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.family),f,keepdata))
14052 {
14053 return qe_invalid;
14054 }
14055
14056
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
50688 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14057 {
14058 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14059 {
14060 tempguy.s_tile=tempguy.e_tile+120;
14061 tempguy.s_width=tempguy.e_width;
14062 tempguy.s_height=tempguy.e_height;
14063 }
14064 else tempguy.s_tile=860;
14065 }
14066
14067
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.cset),f,keepdata))
14068 {
14069 return qe_invalid;
14070 }
14071
14072
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.anim),f,keepdata))
14073 {
14074 return qe_invalid;
14075 }
14076
14077
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14078 {
14079 return qe_invalid;
14080 }
14081
14082
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.frate),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14088 {
14089 return qe_invalid;
14090 }
14091
14092
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 13) // April 2009
14093 {
14094 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14095 {
14096 tempguy.frate *= 2;
14097 tempguy.e_frate *= 2;
14098 }
14099 }
14100
14101
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 14) // May 1 2009
14102 {
14103 if(tempguy.anim==a2FRMSLOW)
14104 {
14105 tempguy.anim=a2FRM;
14106 tempguy.frate *= 2;
14107 }
14108
14109 if(tempguy.e_anim==a2FRMSLOW)
14110 {
14111 tempguy.e_anim=a2FRM;
14112 tempguy.e_frate *= 2;
14113 }
14114
14115 if(tempguy.anim==aFLIPSLOW)
14116 {
14117 tempguy.anim=aFLIP;
14118 tempguy.frate *= 2;
14119 }
14120
14121 if(tempguy.e_anim==aFLIPSLOW)
14122 {
14123 tempguy.e_anim=aFLIP;
14124 tempguy.e_frate *= 2;
14125 }
14126
14127 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14128
14129 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14130
14131 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14132 {
14133 tempguy.anim=a4FRM4DIR;
14134 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14135 }
14136
14137 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14138 {
14139 tempguy.e_anim=a4FRM4DIR;
14140 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14141 }
14142 }
14143
14144
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.dp),f,keepdata))
14145 {
14146 return qe_invalid;
14147 }
14148
14149 //correction for guy fire
14150
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 6)
14151 {
14152 if(i == gFIRE)
14153 tempguy.dp = 2;
14154 }
14155
14156
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14157 {
14158 return qe_invalid;
14159 }
14160
14161
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14162 {
14163 return qe_invalid;
14164 }
14165
14166 //correction for bosses using triple, "rising" fireballs
14167
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 5)
14168 {
14169 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14170 i == eGOHMA3 || i == eGOHMA4)
14171 {
14172 if(tempguy.weapon == ewFireball)
14173 tempguy.weapon = ewFireball2;
14174 }
14175 }
14176
14177
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.rate),f,keepdata))
14178 {
14179 return qe_invalid;
14180 }
14181
14182
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14183 {
14184 return qe_invalid;
14185 }
14186
14187
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.step),f,keepdata))
14188 {
14189 return qe_invalid;
14190 }
14191
14192 // HIGHLY UNORTHODOX UPDATING THING, part 2
14193
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 49152 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
50688 if(fixpolsvoice && tempguy.family==eePOLSV)
14194 {
14195 tempguy.step /= 2;
14196 }
14197
14198
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.homing),f,keepdata))
14199 {
14200 return qe_invalid;
14201 }
14202
14203
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14204 {
14205 return qe_invalid;
14206 }
14207
14208
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14209 {
14210 return qe_invalid;
14211 }
14212
14213
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14214 {
14215
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14216 {
14217 return qe_invalid;
14218 }
14219
14220
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14236 {
14237 return qe_invalid;
14238 }
14239
14240
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14241 {
14242 return qe_invalid;
14243 }
14244
14245
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14246 {
14247 return qe_invalid;
14248 }
14249
14250
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14251 {
14252 return qe_invalid;
14253 }
14254
14255
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14256 {
14257 return qe_invalid;
14258 }
14259
14260
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14261 {
14262 return qe_invalid;
14263 }
14264 50688 }
14265 else
14266 {
14267 int16_t tempMisc;
14268
14269 if(!p_igetw(&tempMisc,f,keepdata))
14270 {
14271 return qe_invalid;
14272 }
14273
14274 tempguy.misc1=tempMisc;
14275
14276 if(!p_igetw(&tempMisc,f,keepdata))
14277 {
14278 return qe_invalid;
14279 }
14280
14281 tempguy.misc2=tempMisc;
14282
14283 if(!p_igetw(&tempMisc,f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287
14288 tempguy.misc3=tempMisc;
14289
14290 if(!p_igetw(&tempMisc,f,keepdata))
14291 {
14292 return qe_invalid;
14293 }
14294
14295 tempguy.misc4=tempMisc;
14296
14297 if(!p_igetw(&tempMisc,f,keepdata))
14298 {
14299 return qe_invalid;
14300 }
14301
14302 tempguy.misc5=tempMisc;
14303
14304 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14305 {
14306 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14307 tempguy.misc5 = 74;
14308 }
14309
14310 if(!p_igetw(&tempMisc,f,keepdata))
14311 {
14312 return qe_invalid;
14313 }
14314
14315 tempguy.misc6=tempMisc;
14316
14317 if(!p_igetw(&tempMisc,f,keepdata))
14318 {
14319 return qe_invalid;
14320 }
14321
14322 tempguy.misc7=tempMisc;
14323
14324 if(!p_igetw(&tempMisc,f,keepdata))
14325 {
14326 return qe_invalid;
14327 }
14328
14329 tempguy.misc8=tempMisc;
14330
14331 if(!p_igetw(&tempMisc,f,keepdata))
14332 {
14333 return qe_invalid;
14334 }
14335
14336 tempguy.misc9=tempMisc;
14337
14338 if(!p_igetw(&tempMisc,f,keepdata))
14339 {
14340 return qe_invalid;
14341 }
14342
14343 tempguy.misc10=tempMisc;
14344 }
14345
14346
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14347 {
14348 return qe_invalid;
14349 }
14350
14351
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14352 {
14353 return qe_invalid;
14354 }
14355
14356
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&(tempguy.extend),f,keepdata))
14357 {
14358 return qe_invalid;
14359 }
14360
14361 //! Enemy Defences
14362
14363 //If a 2.50 quest, use only the 2.5 defences.
14364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14365 {
14366
2/2
✓ Branch 0 taken 963072 times.
✓ Branch 1 taken 50688 times.
1013760 for(int32_t j=0; j<edefLAST; j++)
14367 {
14368
1/2
✓ Branch 0 taken 963072 times.
✗ Branch 1 not taken.
963072 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14369 {
14370 return qe_invalid;
14371 }
14372 963072 }
14373 //then copy the generic script defence to all the new script defences
14374
14375 50688 }
14376
14377
14378
14379
14380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(guyversion >= 18)
14381 {
14382
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14383 {
14384 return qe_invalid;
14385 }
14386
14387
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14388 {
14389 return qe_invalid;
14390 }
14391 50688 }
14392
14393
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion >= 22)
14394 {
14395
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14396 {
14397 return qe_invalid;
14398 }
14399
14400
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14401 {
14402 return qe_invalid;
14403 }
14404 50688 }
14405 else if(guyversion >= 19)
14406 {
14407 int16_t tempMisc;
14408
14409 if(!p_igetw(&tempMisc,f,keepdata))
14410 {
14411 return qe_invalid;
14412 }
14413
14414 tempguy.misc11=tempMisc;
14415
14416 if(!p_igetw(&tempMisc,f,keepdata))
14417 {
14418 return qe_invalid;
14419 }
14420
14421 tempguy.misc12=tempMisc;
14422 }
14423
14424 //If a 2.54 or later quest, use all of the defences.
14425
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion > 24) // Add new guyversion conditional statement
14426 {
14427
2/2
✓ Branch 0 taken 270336 times.
✓ Branch 1 taken 12288 times.
282624 for(int32_t j=edefLAST; j<edefLAST255; j++)
14428 {
14429
1/2
✓ Branch 0 taken 270336 times.
✗ Branch 1 not taken.
270336 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14430 {
14431 return qe_invalid;
14432 }
14433 270336 }
14434 12288 }
14435
14436
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14437 {
14438
2/2
✓ Branch 0 taken 384000 times.
✓ Branch 1 taken 38400 times.
422400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14439 {
14440 384000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14441 384000 }
14442 38400 }
14443
14444 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14445
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion > 25)
14446 {
14447
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14448 {
14449 return qe_invalid;
14450 }
14451
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14452 {
14453 return qe_invalid;
14454 }
14455
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14456 {
14457 return qe_invalid;
14458 }
14459
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14460 {
14461 return qe_invalid;
14462 }
14463
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14464 {
14465 return qe_invalid;
14466 }
14467 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14468
14469 */
14470 12288 }
14471 //More Enemy Editor vars for 2.60
14472
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion > 26)
14473 {
14474
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14475 {
14476 return qe_invalid;
14477 }
14478
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14479 {
14480 return qe_invalid;
14481 }
14482
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14483 {
14484 return qe_invalid;
14485 }
14486
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14487 {
14488 return qe_invalid;
14489 }
14490
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14491 {
14492 return qe_invalid;
14493 }
14494 12288 }
14495
14496
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14497 {
14498 38400 tempguy.wpnsprite = 0;
14499 38400 }
14500
14501
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion > 27)
14502 {
14503
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14504 {
14505 return qe_invalid;
14506 }
14507 12288 }
14508
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14509 {
14510 38400 tempguy.SIZEflags = 0;
14511 38400 }
14512
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion > 28)
14513 {
14514
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14515 {
14516 return qe_invalid;
14517 }
14518
14519 12288 }
14520
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14521 {
14522 38400 tempguy.frozentile = 0;
14523 38400 tempguy.frozencset = 0;
14524 38400 tempguy.frozenclock = 0;
14525
2/2
✓ Branch 0 taken 384000 times.
✓ Branch 1 taken 38400 times.
422400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14526 38400 }
14527
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion >= 30)
14528 {
14529
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14530 {
14531 return qe_invalid;
14532 }
14533
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14534 {
14535 return qe_invalid;
14536 }
14537
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14538 {
14539 return qe_invalid;
14540 }
14541
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 12288 times.
135168 for ( int32_t q = 0; q < 10; q++ ) {
14542
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14543 {
14544 return qe_invalid;
14545 }
14546 122880 }
14547
14548 12288 }
14549
14550
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion >= 34)
14551 {
14552
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14553 {
14554 return qe_invalid;
14555 }
14556
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14557 {
14558 return qe_invalid;
14559 }
14560
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14561 {
14562 return qe_invalid;
14563 }
14564
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14565 {
14566 return qe_invalid;
14567 }
14568
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14569 {
14570 return qe_invalid;
14571 }
14572
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14573 {
14574 return qe_invalid;
14575 }
14576
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14577 {
14578 return qe_invalid;
14579 }
14580
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14581 {
14582 return qe_invalid;
14583 }
14584
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14585 {
14586 return qe_invalid;
14587 }
14588
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14589 {
14590 return qe_invalid;
14591 }
14592
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14593 {
14594 return qe_invalid;
14595 }
14596
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14597 {
14598 return qe_invalid;
14599 }
14600
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14601 {
14602 return qe_invalid;
14603 }
14604
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14605 {
14606 return qe_invalid;
14607 }
14608
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14609 {
14610 return qe_invalid;
14611 }
14612
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14613 {
14614 return qe_invalid;
14615 }
14616
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14617 {
14618 return qe_invalid;
14619 }
14620
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14621 {
14622 return qe_invalid;
14623 }
14624
14625
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 12288 times.
405504 for ( int32_t q = 0; q < 32; q++ ) {
14626
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14627 {
14628 return qe_invalid;
14629 }
14630 393216 }
14631
2/2
✓ Branch 0 taken 393216 times.
✓ Branch 1 taken 12288 times.
405504 for ( int32_t q = 0; q < 32; q++ ) {
14632
1/2
✓ Branch 0 taken 393216 times.
✗ Branch 1 not taken.
393216 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14633 {
14634 return qe_invalid;
14635 }
14636 393216 }
14637
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.script),f,keepdata))
14638 {
14639 return qe_invalid;
14640 }
14641 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14642
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
14643 {
14644
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14645 {
14646 return qe_invalid;
14647 }
14648 98304 }
14649
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 12288 times.
36864 for ( int32_t q = 0; q < 2; q++ )
14650 {
14651
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14652 {
14653 return qe_invalid;
14654 }
14655 24576 }
14656
14657 12288 }
14658
14659
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion >= 37)
14660 {
14661
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14662 {
14663 return qe_invalid;
14664 }
14665 12288 }
14666
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14667
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if(guyversion >= 38)
14668 {
14669
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14670 {
14671 return qe_invalid;
14672 }
14673
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14674 {
14675 return qe_invalid;
14676 }
14677
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14678 {
14679 return qe_invalid;
14680 }
14681
14682 12288 }
14683
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion < 38 )
14684 {
14685 38400 tempguy.misc13 = 0;
14686 38400 tempguy.misc14 = 0;
14687 38400 tempguy.misc15 = 0;
14688 38400 }
14689
14690
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if ( guyversion >= 39 )
14691 {
14692
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
14693 {
14694
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; w++ )
14695 {
14696
1/2
✓ Branch 0 taken 6389760 times.
✗ Branch 1 not taken.
6389760 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14697 {
14698 return qe_invalid;
14699 }
14700 6389760 }
14701
2/2
✓ Branch 0 taken 6389760 times.
✓ Branch 1 taken 98304 times.
6488064 for ( int32_t w = 0; w < 65; w++ )
14702 {
14703
1/2
✓ Branch 0 taken 6389760 times.
✗ Branch 1 not taken.
6389760 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14704 {
14705 return qe_invalid;
14706 }
14707 6389760 }
14708 98304 }
14709
14710
14711 12288 }
14712
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion < 39 ) //apply old InitD strings to both
14713 {
14714
2/2
✓ Branch 0 taken 307200 times.
✓ Branch 1 taken 38400 times.
345600 for ( int32_t q = 0; q < 8; q++ )
14715 {
14716 307200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14717 307200 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14718 307200 }
14719 38400 }
14720
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if ( guyversion >= 40 )
14721 {
14722
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14723 {
14724 return qe_invalid;
14725 }
14726 12288 }
14727
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if ( guyversion < 40 )
14728 {
14729 38400 tempguy.weaponscript = 0;
14730 38400 }
14731 //eweapon script InitD
14732
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
50688 if ( guyversion >= 41 )
14733 {
14734
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 12288 times.
110592 for ( int32_t q = 0; q < 8; q++ )
14735 {
14736
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14737 {
14738 return qe_invalid;
14739 }
14740 98304 }
14741
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if ( guy_cversion < 4 )
14742 {
14743 if ( tempguy.family == eeKEESE )
14744 {
14745
14746 if ( !tempguy.misc1 )
14747 {
14748 tempguy.misc16 = 120;
14749 tempguy.misc17 = 16;
14750
14751 }
14752 }
14753 if ( tempguy.family == eePEAHAT )
14754 {
14755 tempguy.misc16 = 80;
14756 tempguy.misc17 = 16;
14757 }
14758
14759 if ( tempguy.family == eeGHINI )
14760 {
14761 tempguy.misc16 = 120;
14762 tempguy.misc17 = 10;
14763 }
14764
14765 }
14766 12288 }
14767
14768
14769
14770 //default weapon sprites (quest version < 2.54)
14771 //port over old defaults -Z
14772
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 32)
14773 {
14774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38400 times.
38400 if ( tempguy.wpnsprite <= 0 )
14775 {
14776
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31938 times.
✓ Branch 4 taken 296 times.
✓ Branch 5 taken 308 times.
✓ Branch 6 taken 917 times.
✓ Branch 7 taken 483 times.
✓ Branch 8 taken 896 times.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 133 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 743 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 78 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 753 times.
38400 switch(tempguy.weapon)
14777 {
14778 case wNone:
14779 31938 tempguy.wpnsprite = 0; break;
14780
14781 case wSword:
14782 case wBeam:
14783 case wBrang:
14784 case wBomb:
14785 case wSBomb:
14786 case wLitBomb:
14787 case wLitSBomb:
14788 case wArrow:
14789 case wFire:
14790 case wWhistle:
14791 case wBait:
14792 case wWand:
14793 case wMagic:
14794 case wCatching:
14795 case wWind:
14796 case wRefMagic:
14797 case wRefFireball:
14798 case wRefRock:
14799 case wHammer:
14800 case wHookshot:
14801 case wHSHandle:
14802 case wHSChain:
14803 case wSSparkle:
14804 case wFSparkle:
14805 case wSmack:
14806 case wPhantom:
14807 case wCByrna:
14808 case wRefBeam:
14809 case wStomp:
14810 case lwMax:
14811 case wScript1:
14812 case wScript2:
14813 case wScript3:
14814 case wScript4:
14815 case wScript5:
14816 case wScript6:
14817 case wScript7:
14818 case wScript8:
14819 case wScript9:
14820 case wScript10:
14821 case wIce:
14822 //Cannot use any of these weapons yet.
14823 tempguy.wpnsprite = -1;
14824 break;
14825
14826 case wEnemyWeapons:
14827 1281 case ewFireball: tempguy.wpnsprite = 17; break;
14828
14829 296 case ewArrow: tempguy.wpnsprite = 19; break;
14830 308 case ewBrang: tempguy.wpnsprite = 4; break;
14831 917 case ewSword: tempguy.wpnsprite = 20; break;
14832 483 case ewRock: tempguy.wpnsprite = 18; break;
14833 896 case ewMagic: tempguy.wpnsprite = 21; break;
14834 78 case ewBomb: tempguy.wpnsprite = 78; break;
14835 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14836 133 case ewLitBomb: tempguy.wpnsprite = 76; break;
14837 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14838 355 case ewFireTrail: tempguy.wpnsprite = 80; break;
14839 743 case ewFlame: tempguy.wpnsprite = 35; break;
14840 104 case ewWind: tempguy.wpnsprite = 36; break;
14841 78 case ewFlame2: tempguy.wpnsprite = 81; break;
14842 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14843 case ewIce: tempguy.wpnsprite = 83; break;
14844 753 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14845
14846
14847 default: break; //No assign.
14848 }
14849 38400 }
14850 38400 }
14851
14852 //default weapon fire sound (quest version < 2.54)
14853 //port over old defaults and zero new data. -Z
14854
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 34)
14855 {
14856
2/2
✓ Branch 0 taken 1228800 times.
✓ Branch 1 taken 38400 times.
1267200 for ( int32_t q = 0; q < 32; q++ )
14857 {
14858 1228800 tempguy.movement[q] = 0;
14859 1228800 tempguy.new_weapon[q] = 0;
14860
14861 1228800 }
14862
14863 //NPC Script attributes.
14864 38400 tempguy.script = 0; //No scripted enemies existed. -Z
14865
2/2
✓ Branch 0 taken 307200 times.
✓ Branch 1 taken 38400 times.
345600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14866
2/2
✓ Branch 0 taken 76800 times.
✓ Branch 1 taken 38400 times.
115200 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14867
14868 38400 tempguy.misc16 = 0;
14869 38400 tempguy.misc17 = 0;
14870 38400 tempguy.misc18 = 0;
14871 38400 tempguy.misc19 = 0;
14872 38400 tempguy.misc20 = 0;
14873 38400 tempguy.misc21 = 0;
14874 38400 tempguy.misc22 = 0;
14875 38400 tempguy.misc23 = 0;
14876 38400 tempguy.misc24 = 0;
14877 38400 tempguy.misc25 = 0;
14878 38400 tempguy.misc26 = 0;
14879 38400 tempguy.misc27 = 0;
14880 38400 tempguy.misc28 = 0;
14881 38400 tempguy.misc29 = 0;
14882 38400 tempguy.misc30 = 0;
14883 38400 tempguy.misc31 = 0;
14884 38400 tempguy.misc32 = 0;
14885
14886 //old default sounds
14887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38400 times.
38400 if ( tempguy.firesfx <= 0 )
14888 {
14889
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31938 times.
✓ Branch 4 taken 296 times.
✓ Branch 5 taken 308 times.
✓ Branch 6 taken 917 times.
✓ Branch 7 taken 483 times.
✓ Branch 8 taken 896 times.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 133 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 743 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 78 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 753 times.
38400 switch(tempguy.weapon)
14890 {
14891 case wNone:
14892 31938 tempguy.firesfx = 0; break;
14893
14894 case wSword:
14895 case wBeam:
14896 case wBrang:
14897 case wBomb:
14898 case wSBomb:
14899 case wLitBomb:
14900 case wLitSBomb:
14901 case wArrow:
14902 case wFire:
14903 case wWhistle:
14904 case wBait:
14905 case wWand:
14906 case wMagic:
14907 case wCatching:
14908 case wWind:
14909 case wRefMagic:
14910 case wRefFireball:
14911 case wRefRock:
14912 case wHammer:
14913 case wHookshot:
14914 case wHSHandle:
14915 case wHSChain:
14916 case wSSparkle:
14917 case wFSparkle:
14918 case wSmack:
14919 case wPhantom:
14920 case wCByrna:
14921 case wRefBeam:
14922 case wStomp:
14923 case lwMax:
14924 case wScript1:
14925 case wScript2:
14926 case wScript3:
14927 case wScript4:
14928 case wScript5:
14929 case wScript6:
14930 case wScript7:
14931 case wScript8:
14932 case wScript9:
14933 case wScript10:
14934 case wIce:
14935 //Cannot use any of these weapons yet.
14936 tempguy.firesfx = -1;
14937 break;
14938
14939 case wEnemyWeapons:
14940 1281 case ewFireball: tempguy.firesfx = 40; break;
14941
14942 296 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14943 308 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14944 917 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14945 483 case ewRock: tempguy.firesfx = 51; break;
14946 896 case ewMagic: tempguy.firesfx = 32; break;
14947 78 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14948 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14949 133 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14950 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14951 355 case ewFireTrail: tempguy.firesfx = 13; break;
14952 743 case ewFlame: tempguy.firesfx = 13; break;
14953 104 case ewWind: tempguy.firesfx = 32; break;
14954 78 case ewFlame2: tempguy.firesfx = 13; break;
14955 case ewFlame2Trail: tempguy.firesfx = 13; break;
14956 case ewIce: tempguy.firesfx = 44; break;
14957 753 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14958
14959 //what about special attacks (e.g. summoning == 56)
14960 default: break; //No assign.
14961 }
14962 38400 }
14963 38400 }
14964
14965 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14966
4/6
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
✓ Branch 2 taken 12288 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12288 times.
50688 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14967 {
14968
2/2
✓ Branch 0 taken 3505 times.
✓ Branch 1 taken 34895 times.
38400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14969 38400 }
14970 //Keese and bat halt rates.
14971
3/4
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38400 times.
50688 if ( guyversion < 42 && guy_cversion < 4 )
14972 {
14973
14974
2/2
✓ Branch 0 taken 37881 times.
✓ Branch 1 taken 519 times.
38400 if ( tempguy.family == eeKEESE )
14975 {
14976
14977
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 318 times.
519 if ( !tempguy.misc1 )
14978 {
14979 318 tempguy.misc16 = 120;
14980 318 tempguy.misc17 = 16;
14981
14982 318 }
14983 519 }
14984
2/2
✓ Branch 0 taken 38237 times.
✓ Branch 1 taken 163 times.
38400 if ( tempguy.family == eePEAHAT )
14985 {
14986 163 tempguy.misc16 = 80;
14987 163 tempguy.misc17 = 16;
14988 163 }
14989
2/2
✓ Branch 0 taken 38325 times.
✓ Branch 1 taken 75 times.
38400 if ( tempguy.family == eeGHINI )
14990 {
14991 75 tempguy.misc16 = 120;
14992 75 tempguy.misc17 = 10;
14993 75 }
14994
14995
14996 38400 }
14997
14998
14999 //miscellaneous other corrections
15000 //fix the mirror wizzrobe -DD
15001
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 7)
15002 {
15003 if(i == eMWIZ)
15004 {
15005 tempguy.misc2 = 0;
15006 tempguy.misc4 = 1;
15007 }
15008 }
15009
15010
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 8)
15011 {
15012 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15013 {
15014 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15015 tempguy.misc5 = 4; //neck length in segments
15016 tempguy.misc6 = 8; //neck offset from first body tile
15017 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15018 tempguy.misc8 = 168; //head offset from first body tile
15019 tempguy.misc9 = 228; //flying head offset from first body tile
15020
15021 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15022 {
15023 tempguy.misc6 += 10; //neck offset from first body tile
15024 tempguy.misc8 -= 12; //head offset from first body tile
15025 }
15026 }
15027 }
15028
15029
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15030 {
15031 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15032 tempguy.bosspal = spDIG;
15033 }
15034
15035
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 11) // December 2007 - Spinning Tile fix
15036 {
15037 if(tempguy.family==eeSPINTILE)
15038 {
15039 tempguy.flags |= guy_superman;
15040 tempguy.item_set = 0; // Don't drop items
15041 tempguy.step = 300;
15042 }
15043 }
15044
15045
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15046 {
15047 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15048 {
15049 if(tempguy.family==eeROPE)
15050 {
15051 tempguy.flags2 &= ~guy_flashing;
15052 }
15053 }
15054
15055 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15056 {
15057 if(tempguy.family==eeBUBBLE)
15058 {
15059 tempguy.flags2 &= ~guy_flashing;
15060 }
15061 }
15062
15063 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15064 {
15065 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15066 {
15067 tempguy.flags2 |= guy_blinking;
15068 }
15069
15070 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15071 {
15072 tempguy.flags2 |= guy_transparent;
15073 }
15074 }
15075 }
15076
15077
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15078 {
15079 if(i==gFIRE)
15080 {
15081 tempguy.e_anim = aFLIP;
15082 tempguy.e_frate = 24;
15083 }
15084
15085 if(i==gFAIRY)
15086 {
15087 tempguy.e_anim = a2FRM;
15088 tempguy.e_frate = 16;
15089 }
15090 }
15091
15092
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15093 {
15094 if(i==0) Z_message("Updating guys to version 16...\n");
15095
15096 update_guy_1(&tempguy);
15097
15098 if(i==eMPOLSV)
15099 {
15100 tempguy.defense[edefARROW] = edCHINK;
15101 tempguy.defense[edefMAGIC] = ed1HKO;
15102 tempguy.defense[edefREFMAGIC] = ed1HKO;
15103 }
15104 }
15105
15106
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 17) // December 2009
15107 {
15108 if(tempguy.family==eePROJECTILE)
15109 {
15110 tempguy.misc1 = 0;
15111 }
15112 }
15113
15114
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 18) // January 2010
15115 {
15116 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15117 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15118
15119 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15120 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15121
15122 if(tempguy.family == eeAQUA)
15123 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15124 else if(tempguy.family == eeMANHAN)
15125 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15126 else if(tempguy.family==eePATRA)
15127 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15128 else if(tempguy.family==eeGHOMA)
15129 {
15130 for(int32_t j=0; j<edefLAST; j++)
15131 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15132
15133 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15134
15135 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15136
15137 tempguy.misc1--;
15138 }
15139 else if(tempguy.family == eeGLEEOK)
15140 {
15141 for(int32_t j=0; j<edefLAST; j++)
15142 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15143
15144 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15145 }
15146 else if(tempguy.family == eeARMOS)
15147 {
15148 tempguy.family=eeWALK;
15149 tempguy.hrate = 0;
15150 tempguy.misc10 = tempguy.misc1;
15151 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15152 tempguy.misc9 = e9tARMOS;
15153 }
15154 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15155 {
15156 tempguy.family=eeWALK;
15157 tempguy.hrate = 0;
15158 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15159 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15160 }
15161
15162 // Spawn animation flags
15163 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15164 tempguy.flags |= guy_fadeflicker;
15165 else
15166 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15167 }
15168
15169
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 20) // April 2010
15170 {
15171 if(tempguy.family == eeTRAP)
15172 {
15173 tempguy.misc2 = tempguy.misc10;
15174
15175 if(tempguy.misc10>=1)
15176 {
15177 tempguy.misc1++;
15178 }
15179
15180 tempguy.misc10 = 0;
15181 }
15182
15183 // Bomb Blast fix
15184 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15185 tempguy.weapon = ewLitBomb;
15186 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15187 tempguy.weapon = ewLitSBomb;
15188 }
15189
15190
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 21) // September 2011
15191 {
15192 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15193 {
15194 if(tempguy.family == eeKEESETRIB)
15195 {
15196 tempguy.family = eeKEESE;
15197 tempguy.misc2 = e2tKEESETRIB;
15198 tempguy.misc1 = 0;
15199 }
15200
15201 tempguy.rate = 2;
15202 tempguy.hrate = 8;
15203 tempguy.homing = 0;
15204 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15205 }
15206 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15207 {
15208 if(tempguy.family == eePEAHAT)
15209 {
15210 tempguy.rate = 4;
15211 tempguy.step = 62;
15212 }
15213 else
15214 tempguy.step = 25;
15215
15216 tempguy.hrate = 8;
15217 tempguy.homing = 0;
15218 }
15219 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15220 {
15221 if(tempguy.family == eeMANHAN)
15222 tempguy.step=50;
15223
15224 tempguy.hrate = 16;
15225 tempguy.homing = 0;
15226 }
15227 else if(tempguy.family == eeGLEEOK)
15228 {
15229 tempguy.rate = 2;
15230 tempguy.homing = 0;
15231 tempguy.hrate = 9;
15232 tempguy.step=89;
15233 }
15234 else if(tempguy.family == eeGHINI)
15235 {
15236 tempguy.rate = 4;
15237 tempguy.hrate = 12;
15238 tempguy.step=62;
15239 tempguy.homing = 0;
15240 }
15241
15242 // Bigdig random rate fix
15243 if(tempguy.family==eeDIG && tempguy.misc10==1)
15244 {
15245 tempguy.rate = 2;
15246 }
15247 }
15248
15249
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(guyversion < 24) // November 2012
15250 {
15251 if(tempguy.family==eeLANM)
15252 tempguy.misc3 = 1;
15253 else if(tempguy.family==eeMOLD)
15254 tempguy.misc2 = 0;
15255 }
15256
15257
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15258 {
15259
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 37752 times.
38400 if(tempguy.family!=eeDIG)
15260 {
15261 37752 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15262 37752 }
15263
15264 38400 }
15265 // does not seem to solve the issue!
15266
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if ( Header->zelda_version <= 0x210 )
15267 {
15268 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15269 if ( tempguy.family == eeDONGO )
15270 {
15271 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15272 }
15273 }
15274
15275
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion >= 42)
15276 {
15277
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 1024 times.
12288 if(guyversion >= 47)
15278 {
15279
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15280 {
15281 return qe_invalid;
15282 }
15283 11264 }
15284 else
15285 {
15286 byte fl;
15287
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15288 {
15289 return qe_invalid;
15290 }
15291 1024 tempguy.moveflags = fl;
15292 }
15293 12288 }
15294 else
15295 {
15296
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30017 times.
✓ Branch 2 taken 1182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✓ Branch 5 taken 272 times.
✓ Branch 6 taken 237 times.
✓ Branch 7 taken 5734 times.
38400 switch(tempguy.family)
15297 {
15298 //No gravity; floats over pits
15299 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15300 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15301 //Special (bosses, etc)
15302 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15303 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15304 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15305 30017 tempguy.moveflags = FLAG_CAN_PITWALK;
15306 30017 break;
15307 //No gravity, but falls in pits
15308 case eeLEV:
15309 512 tempguy.moveflags = FLAG_CAN_PITFALL;
15310 512 break;
15311 //Bosses that respect pits
15312 case eeDONGO:
15313 272 tempguy.moveflags = FLAG_OBEYS_GRAV;
15314 272 break;
15315 case eeLANM:
15316 237 tempguy.moveflags = 0;
15317 237 break;
15318 //Gravity, floats over pits
15319 case eeWIZZ: case eeWALLM: case eeGHINI:
15320 1182 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15321 1182 break;
15322 //Gravity and falls in pits
15323 case eeWALK:
15324
4/4
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 276 times.
✓ Branch 3 taken 5143 times.
5734 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15325 591 break;
15326 [[fallthrough]];
15327 case eeOTHER:
15328 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15329 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15330 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15331 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15332 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15333 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15334 5589 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15335 5589 }
15336 }
15337
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 43)
15338 {
15339
2/2
✓ Branch 0 taken 31199 times.
✓ Branch 1 taken 7201 times.
38400 switch(tempguy.family)
15340 {
15341 //No gravity; floats over pits
15342 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15343 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15344 //Special (bosses, etc)
15345 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15346 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15347 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15348 case eeWIZZ: case eeWALLM: case eeGHINI:
15349 //Gravity, floats over pits
15350 31199 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15351 31199 break;
15352 }
15353 38400 }
15354
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if (guyversion < 44)
15355 {
15356
2/2
✓ Branch 0 taken 38038 times.
✓ Branch 1 taken 362 times.
38400 if ( tempguy.family == eeGHOMA )
15357 {
15358 362 tempguy.flags |= guy_fadeinstant;
15359 362 }
15360 38400 }
15361
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if (guyversion > 44)
15362 {
15363
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15364 {
15365 return qe_invalid;
15366 }
15367
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15368 {
15369 return qe_invalid;
15370 }
15371
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15372 {
15373 return qe_invalid;
15374 }
15375 12288 }
15376 else
15377 {
15378
2/2
✓ Branch 0 taken 38251 times.
✓ Branch 1 taken 149 times.
38400 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15379 38400 tempguy.spr_death = iwDeath;
15380 38400 tempguy.spr_spawn = iwSpawn;
15381 }
15382
15383
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 38400 times.
50688 if(guyversion < 46)
15384 {
15385
4/4
✓ Branch 0 taken 5734 times.
✓ Branch 1 taken 32666 times.
✓ Branch 2 taken 5419 times.
✓ Branch 3 taken 315 times.
38400 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15386 {
15387 315 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15388 315 }
15389 38400 }
15390
15391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(keepdata)
15392 {
15393 50688 guysbuf[i] = tempguy;
15394 50688 }
15395 50688 }
15396 99 }
15397
15398 99 return 0;
15399 108 }
15400
15401 void update_guy_1(guydata *tempguy) // November 2009
15402 {
15403 bool doesntcount = false;
15404 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15405
15406 switch(tempguy->family)
15407 {
15408 case 1: //eeWALK
15409 switch(tempguy->misc10)
15410 {
15411 case 0: //Stalfos
15412 if(tempguy->misc1==1) // Fires four projectiles at once
15413 tempguy->misc1=4;
15414
15415 break;
15416
15417 case 1: //Darknut
15418 goto darknuts;
15419 break;
15420 }
15421
15422 tempguy->misc10 = 0;
15423 break;
15424
15425 case 2: //eeSHOOT
15426 tempguy->family = eeWALK;
15427
15428 switch(tempguy->misc10)
15429 {
15430 case 0: //Octorok
15431 if(tempguy->misc1==1||tempguy->misc1==2)
15432 {
15433 tempguy->misc1=e1tFIREOCTO;
15434 tempguy->misc2=e2tFIREOCTO;
15435 }
15436 else tempguy->misc1 = 0;
15437
15438 tempguy->misc6=tempguy->misc4;
15439 tempguy->misc4=tempguy->misc3;
15440 tempguy->misc3=0;
15441 break;
15442
15443 case 1: // Moblin
15444 tempguy->misc1 = 0;
15445 break;
15446
15447 case 2: //Lynel
15448 tempguy->misc6=tempguy->misc1+1;
15449 tempguy->misc1=0;
15450 break;
15451
15452 case 3: //Stalfos 2
15453 if(tempguy->misc1==1) // Fires four projectiles at once
15454 tempguy->misc1=e1t4SHOTS;
15455 else tempguy->misc1 = 0;
15456
15457 break;
15458
15459 case 4: //Darknut 5
15460 darknuts:
15461 tempguy->defense[edefFIRE] = edIGNORE;
15462 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15463 tempguy->defense[edefHOOKSHOT] = 0;
15464 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15465 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15466
15467 if(tempguy->misc1==1)
15468 tempguy->misc1=2;
15469 else if(tempguy->misc1==2)
15470 {
15471 tempguy->misc4=tempguy->misc3;
15472 tempguy->misc3=tempguy->misc2;
15473 tempguy->misc2=e2tSPLIT;
15474 tempguy->misc1 = 0;
15475 }
15476 else tempguy->misc1 = 0;
15477
15478 tempguy->flags |= inv_front;
15479
15480 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15481 tempguy->flags |= guy_bkshield;
15482
15483 break;
15484 }
15485
15486 tempguy->misc10 = 0;
15487 break;
15488
15489 /*
15490 case 9: //eeARMOS
15491 tempguy->family = eeWALK;
15492 break;
15493 */
15494 case 11: //eeGEL
15495 case 33: //eeGELTRIB
15496 if(tempguy->family==33)
15497 {
15498 tempguy->misc4 = 1;
15499
15500 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15501 tempguy->misc3 = tempguy->misc2;
15502
15503 tempguy->misc2 = e2tTRIBBLE;
15504 }
15505 else
15506 {
15507 tempguy->misc4 = 0;
15508 tempguy->misc3 = 0;
15509 tempguy->misc2 = 0;
15510 }
15511
15512 tempguy->family = eeWALK;
15513
15514 if(tempguy->misc1)
15515 {
15516 tempguy->misc1=1;
15517 tempguy->weapon = ewFireTrail;
15518 }
15519
15520 break;
15521
15522 case 34: //eeZOLTRIB
15523 case 12: //eeZOL
15524 tempguy->misc4=tempguy->misc3;
15525 tempguy->misc3=tempguy->misc2;
15526 tempguy->family = eeWALK;
15527 tempguy->misc2=e2tSPLITHIT;
15528
15529 if(tempguy->misc1)
15530 {
15531 tempguy->misc1=1;
15532 tempguy->weapon = ewFireTrail;
15533 }
15534
15535 break;
15536
15537 case 13: //eeROPE
15538 tempguy->family = eeWALK;
15539 tempguy->misc9 = e9tROPE;
15540
15541 if(tempguy->misc1)
15542 {
15543 tempguy->misc4 = tempguy->misc3;
15544 tempguy->misc3 = tempguy->misc2;
15545 tempguy->misc2 = e2tBOMBCHU;
15546 }
15547
15548 tempguy->misc1 = 0;
15549 break;
15550
15551 case 14: //eeGORIYA
15552 tempguy->family = eeWALK;
15553
15554 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15555
15556 break;
15557
15558 case 17: //eeBUBBLE
15559 tempguy->family = eeWALK;
15560 tempguy->misc8 = tempguy->misc2;
15561 tempguy->misc7 = tempguy->misc1 + 1;
15562 tempguy->misc1 = tempguy->misc2 = 0;
15563
15564 //fallthrogh
15565 case eeTRAP:
15566 case eeROCK:
15567 doesntcount = true;
15568 break;
15569
15570 case 35: //eeVIRETRIB
15571 case 18: //eeVIRE
15572 tempguy->family = eeWALK;
15573 tempguy->misc4=tempguy->misc3;
15574 tempguy->misc3=tempguy->misc2;
15575 tempguy->misc2=e2tSPLITHIT;
15576 tempguy->misc9=e9tVIRE;
15577 break;
15578
15579 case 19: //eeLIKE
15580 tempguy->family = eeWALK;
15581 tempguy->misc7 = e7tEATITEMS;
15582 tempguy->misc8=95;
15583 break;
15584
15585 case 20: //eePOLSV
15586 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15587 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15588 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15589 tempguy->defense[edefARROW] = ed1HKO;
15590 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15591 tempguy->family = eeWALK;
15592 tempguy->misc9 = e9tPOLSVOICE;
15593 tempguy->rate = 4;
15594 tempguy->homing = 32;
15595 tempguy->hrate = 10;
15596 tempguy->grumble = 0;
15597 break;
15598
15599 case eeWIZZ:
15600 if(tempguy->misc4)
15601 {
15602 for(int32_t i=0; i < edefLAST; i++)
15603 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15604 }
15605 else
15606 {
15607 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15608 tempguy->defense[edefMAGIC] = edCHINK;
15609 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15610 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15611 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15612 }
15613
15614 break;
15615
15616 case eePEAHAT:
15617 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15618
15619 if(!(tempguy->flags & guy_bhit))
15620 tempguy->defense[edefBRANG] = edSTUNONLY;
15621
15622 break;
15623
15624 case eeLEV:
15625 tempguy->defense[edefSTOMP] = edCHINK;
15626 break;
15627 }
15628
15629 // Old flags
15630 if(tempguy->flags & guy_superman)
15631 {
15632 for(int32_t i = 0; i < edefLAST; i++)
15633 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15634 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15635 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15636 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15637 }
15638
15639 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15640
15641 if(doesntcount)
15642 tempguy->flags |= (guy_doesntcount);
15643 }
15644
15645
15646 187336 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15647 {
15648 byte tempbyte, padding;
15649 int32_t extras, secretcombos;
15650 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->valid),f,true))
15652 {
15653 return qe_invalid;
15654 }
15655
15656
15657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->guy),f,true))
15658 {
15659 return qe_invalid;
15660 }
15661
15662
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15665 {
15666 return qe_invalid;
15667 }
15668
15669 6864 temp_mapscr->str=tempbyte;
15670 6864 }
15671 else
15672 {
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
180472 if(!p_igetw(&(temp_mapscr->str),f,true))
15674 {
15675 return qe_invalid;
15676 }
15677 }
15678
15679
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->room),f,true))
15680 {
15681 return qe_invalid;
15682 }
15683
15684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->item),f,true))
15685 {
15686 return qe_invalid;
15687 }
15688
15689
3/6
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 152592 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15690 {
15691 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15692 34744 }
15693 else
15694 {
15695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15696 return qe_invalid;
15697 }
15698
15699
2/4
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187336 if((Header->zelda_version < 0x192)||
15700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
180472 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15701 {
15702
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15703 {
15704 return qe_invalid;
15705 }
15706 6864 }
15707
15708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15709 {
15710 return qe_invalid;
15711 }
15712
15713
2/2
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
187336 if(Header->zelda_version < 0x193)
15714 {
15715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15716 {
15717 return qe_invalid;
15718 }
15719 6864 }
15720
15721
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15722 {
15723
2/2
✓ Branch 0 taken 457776 times.
✓ Branch 1 taken 152592 times.
610368 for(int32_t i=1; i<4; i++)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15726 {
15727 return qe_invalid;
15728 }
15729 457776 }
15730 152592 }
15731 else
15732 {
15733 34744 temp_mapscr->tilewarptype[1]=0;
15734 34744 temp_mapscr->tilewarptype[2]=0;
15735 34744 temp_mapscr->tilewarptype[3]=0;
15736 }
15737
15738
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15739 {
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
180472 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15741 {
15742 return qe_invalid;
15743 }
15744 180472 }
15745
15746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15747 {
15748 return qe_invalid;
15749 }
15750
15751 187336 temp_mapscr->warpreturnx[1]=0;
15752 187336 temp_mapscr->warpreturnx[2]=0;
15753 187336 temp_mapscr->warpreturnx[3]=0;
15754
15755
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15756 {
15757
2/2
✓ Branch 0 taken 457776 times.
✓ Branch 1 taken 152592 times.
610368 for(int32_t i=1; i<4; i++)
15758 {
15759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15760 {
15761 return qe_invalid;
15762 }
15763 457776 }
15764 152592 }
15765
15766
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15767 {
15768 return qe_invalid;
15769 }
15770
15771 187336 temp_mapscr->warpreturny[1]=0;
15772 187336 temp_mapscr->warpreturny[2]=0;
15773 187336 temp_mapscr->warpreturny[3]=0;
15774
15775
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15776 {
15777
2/2
✓ Branch 0 taken 457776 times.
✓ Branch 1 taken 152592 times.
610368 for(int32_t i=1; i<4; i++)
15778 {
15779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15780 {
15781 return qe_invalid;
15782 }
15783 457776 }
15784
15785
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(version>=18)
15786 {
15787
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15788 {
15789 return qe_invalid;
15790 }
15791 152592 }
15792 else
15793 {
15794 byte temp;
15795
15796 if(!p_getc(&temp,f,true))
15797 {
15798 return qe_invalid;
15799 }
15800
15801 temp_mapscr->warpreturnc=temp<<8|temp;
15802 }
15803 152592 }
15804
15805
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->stairx),f,true))
15806
15807 {
15808 return qe_invalid;
15809 }
15810
15811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->stairy),f,true))
15812 {
15813 return qe_invalid;
15814 }
15815
15816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->itemx),f,true))
15817 {
15818 return qe_invalid;
15819 }
15820
15821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->itemy),f,true))
15822 {
15823 return qe_invalid;
15824 }
15825
15826
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version > 15) // February 2009
15827 {
15828
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_igetw(&(temp_mapscr->color),f,true))
15829 {
15830 return qe_invalid;
15831 }
15832 152592 }
15833 else
15834 {
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15836 {
15837 return qe_invalid;
15838 }
15839
15840 34744 temp_mapscr->color = (word) tempbyte;
15841 }
15842
15843
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15844 {
15845 return qe_invalid;
15846 }
15847
15848
2/2
✓ Branch 0 taken 749344 times.
✓ Branch 1 taken 187336 times.
936680 for(int32_t k=0; k<4; k++)
15849 {
15850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 749344 times.
749344 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15851 {
15852 return qe_invalid;
15853
15854 }
15855 749344 }
15856
15857
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
187336 if(version <= 11)
15858 {
15859
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
15860 {
15861 return qe_invalid;
15862 }
15863
15864 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15865
15866
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15867 {
15868 for(int32_t i=1; i<4; i++)
15869 {
15870 if(!p_getc(&(tempbyte),f,true))
15871 {
15872 return qe_invalid;
15873 }
15874
15875 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15876 }
15877 }
15878 else
15879 {
15880 34744 temp_mapscr->tilewarpdmap[1]=0;
15881 34744 temp_mapscr->tilewarpdmap[2]=0;
15882 34744 temp_mapscr->tilewarpdmap[3]=0;
15883 }
15884 34744 }
15885 else
15886 {
15887
2/2
✓ Branch 0 taken 610368 times.
✓ Branch 1 taken 152592 times.
762960 for(int32_t i=0; i<4; i++)
15888 {
15889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610368 times.
610368 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15890 {
15891 return qe_invalid;
15892 }
15893 610368 }
15894 }
15895
15896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15897 {
15898 return qe_invalid;
15899 }
15900
15901
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15902 {
15903
2/2
✓ Branch 0 taken 457776 times.
✓ Branch 1 taken 152592 times.
610368 for(int32_t i=1; i<4; i++)
15904 {
15905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15906 {
15907 return qe_invalid;
15908 }
15909 457776 }
15910 152592 }
15911 else
15912 {
15913 34744 temp_mapscr->tilewarpscr[1]=0;
15914 34744 temp_mapscr->tilewarpscr[2]=0;
15915 34744 temp_mapscr->tilewarpscr[3]=0;
15916 }
15917
15918
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version >= 15)
15919 {
15920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15921 {
15922 return qe_invalid;
15923 }
15924 152592 }
15925 else
15926 {
15927 34744 temp_mapscr->tilewarpoverlayflags=0;
15928 }
15929
15930
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15931 {
15932 return qe_invalid;
15933 }
15934
15935
2/2
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
187336 if(Header->zelda_version < 0x193)
15936 {
15937
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15938 {
15939 return qe_invalid;
15940 }
15941
15942 6864 }
15943
15944
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15945 {
15946 if(!p_getc(&padding,f,true))
15947 {
15948 return qe_invalid;
15949 }
15950 }
15951
15952
2/2
✓ Branch 0 taken 1873360 times.
✓ Branch 1 taken 187336 times.
2060696 for(int32_t k=0; k<10; k++)
15953 {
15954 /*
15955 if (!temp_mapscr->enemy[k])
15956 {
15957 continue;
15958 }
15959 */
15960
3/6
✓ Branch 0 taken 1804720 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1804720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1873360 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15961 {
15962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
15963 {
15964 return qe_invalid;
15965 }
15966
15967 68640 temp_mapscr->enemy[k]=tempbyte;
15968 68640 }
15969 else
15970 {
15971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1804720 times.
1804720 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15972 {
15973 return qe_invalid;
15974 }
15975 }
15976
15977
3/6
✓ Branch 0 taken 1804720 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1804720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1873360 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15978 {
15979 //using enumerations here is dangerous
15980 //very easy to break old quests -DD
15981
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15982 {
15983 788 temp_mapscr->enemy[k]+=5;
15984 788 }
15985
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15986 {
15987 40 temp_mapscr->enemy[k]+=1;
15988 40 }
15989 68640 }
15990
15991
2/2
✓ Branch 0 taken 1525920 times.
✓ Branch 1 taken 347440 times.
1873360 if(version < 9)
15992 {
15993
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
15994 {
15995 29025 temp_mapscr->enemy[k]+=10;
15996 29025 }
15997 347440 }
15998 //don't read in any invalid data
15999
2/2
✓ Branch 0 taken 1873340 times.
✓ Branch 1 taken 20 times.
1873360 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16000 {
16001 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16002 20 temp_mapscr->enemy[k] = 0;
16003 20 }
16004 1873360 }
16005
16006
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->pattern),f,true))
16007 {
16008 return qe_invalid;
16009 }
16010
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16012 {
16013 return qe_invalid;
16014 }
16015
16016
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16017 {
16018
2/2
✓ Branch 0 taken 457776 times.
✓ Branch 1 taken 152592 times.
610368 for(int32_t i=1; i<4; i++)
16019 {
16020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16021 {
16022 return qe_invalid;
16023 }
16024 457776 }
16025 152592 }
16026 else
16027 {
16028 34744 temp_mapscr->sidewarptype[1]=0;
16029 34744 temp_mapscr->sidewarptype[2]=0;
16030 34744 temp_mapscr->sidewarptype[3]=0;
16031 }
16032
16033
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version >= 15)
16034 {
16035
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16036 {
16037 return qe_invalid;
16038 }
16039 152592 }
16040 else
16041 {
16042 34744 temp_mapscr->sidewarpoverlayflags=0;
16043 }
16044
16045
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16046 {
16047 return qe_invalid;
16048 }
16049
16050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16051 {
16052 return qe_invalid;
16053 }
16054
16055
2/2
✓ Branch 0 taken 749344 times.
✓ Branch 1 taken 187336 times.
936680 for(int32_t k=0; k<4; k++)
16056 {
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 749344 times.
749344 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061 749344 }
16062
16063
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16064 {
16065 return qe_invalid;
16066 }
16067
16068
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16069 {
16070
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 457776 times.
610368 for(int32_t i=1; i<4; i++)
16071 {
16072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457776 times.
457776 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16073 {
16074 return qe_invalid;
16075 }
16076 457776 }
16077 152592 }
16078 else
16079 {
16080 34744 temp_mapscr->sidewarpscr[1]=0;
16081 34744 temp_mapscr->sidewarpscr[2]=0;
16082 34744 temp_mapscr->sidewarpscr[3]=0;
16083 }
16084
16085
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
187336 if(version <= 11)
16086 {
16087
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16088 {
16089 return qe_invalid;
16090 }
16091
16092 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16093
16094
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16095 {
16096 for(int32_t i=1; i<4; i++)
16097 {
16098 if(!p_getc(&(tempbyte),f,true))
16099 {
16100 return qe_invalid;
16101 }
16102
16103 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16104 }
16105 }
16106 else
16107 {
16108 34744 temp_mapscr->sidewarpdmap[1]=0;
16109 34744 temp_mapscr->sidewarpdmap[2]=0;
16110 34744 temp_mapscr->sidewarpdmap[3]=0;
16111 }
16112 34744 }
16113 else
16114 {
16115
2/2
✓ Branch 0 taken 610368 times.
✓ Branch 1 taken 152592 times.
762960 for(int32_t i=0; i<4; i++)
16116 {
16117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610368 times.
610368 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16118 {
16119 return qe_invalid;
16120 }
16121 610368 }
16122 }
16123
16124
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16125 {
16126
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16127 {
16128 return qe_invalid;
16129 }
16130 152592 }
16131 34744 else temp_mapscr->sidewarpindex = 0;
16132
16133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16134 {
16135 return qe_invalid;
16136 }
16137
16138
2/2
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
187336 if(Header->zelda_version < 0x193)
16139 {
16140
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16141 {
16142 return qe_invalid;
16143 }
16144 6864 }
16145
16146
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16147 {
16148 return qe_invalid;
16149 }
16150
16151
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16152 {
16153 return qe_invalid;
16154 }
16155
16156
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(!p_getc(&(temp_mapscr->flags),f,true))
16157 {
16158 return qe_invalid;
16159 }
16160
16161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->flags2),f,true))
16162 {
16163 return qe_invalid;
16164 }
16165
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
187336 if(!p_getc(&(temp_mapscr->flags3),f,true))
16167 {
16168 return qe_invalid;
16169 }
16170
16171
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16172 //if (version>2)
16173 {
16174
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->flags4),f,true))
16175 {
16176 return qe_invalid;
16177 }
16178 152592 }
16179
16180
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16181 {
16182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->flags5),f,true))
16183 {
16184 return qe_invalid;
16185 }
16186
16187
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16188 {
16189 return qe_invalid;
16190 }
16191
16192
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16193 {
16194 return qe_invalid;
16195 }
16196
16197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(temp_mapscr->flags5&32)
16198 {
16199 temp_mapscr->flags5 &= ~32;
16200 temp_mapscr->noreset |= 48;
16201 }
16202
16203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(version<8)
16204 {
16205 if(temp_mapscr->noreset&1)
16206 {
16207 temp_mapscr->noreset|=8192;
16208 }
16209
16210 if(temp_mapscr->nocarry&1)
16211 {
16212 temp_mapscr->nocarry|=8192;
16213 temp_mapscr->nocarry&=~1;
16214 }
16215 }
16216 152592 }
16217 else
16218 {
16219 34744 temp_mapscr->flags5 = 0;
16220 34744 temp_mapscr->noreset = 0;
16221 34744 temp_mapscr->nocarry = 0;
16222 }
16223
16224
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16225 {
16226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->flags6),f,true))
16227 {
16228 return qe_invalid;
16229 }
16230 152592 }
16231
16232
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version>5)
16233 {
16234
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->flags7),f,true))
16235 {
16236 return qe_invalid;
16237 }
16238
16239
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->flags8),f,true))
16240 {
16241 return qe_invalid;
16242 }
16243
16244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->flags9),f,true))
16245 {
16246 return qe_invalid;
16247 }
16248
16249
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->flags10),f,true))
16250 {
16251 return qe_invalid;
16252 }
16253
16254
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16255 {
16256 return qe_invalid;
16257 }
16258 152592 }
16259 else
16260 {
16261 34744 temp_mapscr->csensitive=1;
16262 }
16263
16264
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
187336 if(version<14) // August 2007: screen SFX added
16265 {
16266
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16267 {
16268 100 temp_mapscr->bosssfx=
16269
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16270 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16271 WAV_ROAR;
16272 100 }
16273
16274
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16275 {
16276 91 temp_mapscr->oceansfx=WAV_SEA;
16277 91 }
16278
16279 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16280 ? 0 : WAV_SECRET;
16281
16282 34744 temp_mapscr->flags3 &= ~66; //64|2
16283 34744 temp_mapscr->flags2 &= ~32;
16284 34744 temp_mapscr->flags &= ~136; // 128|8
16285 34744 }
16286 else
16287 {
16288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16289 {
16290 return qe_invalid;
16291 }
16292
16293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16294 {
16295 return qe_invalid;
16296 }
16297
16298
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16299 {
16300 return qe_invalid;
16301 }
16302 }
16303
16304
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
187336 if(version<15) // October 2007: another SFX
16305 {
16306 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16307 34744 }
16308 else
16309 {
16310
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16311 {
16312 return qe_invalid;
16313 }
16314 }
16315
16316
16317
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16318 {
16319
2/2
✓ Branch 0 taken 1082832 times.
✓ Branch 1 taken 180472 times.
1263304 for(int32_t k=0; k<6; k++)
16320 {
16321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1082832 times.
1082832 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16322 {
16323 return qe_invalid;
16324 }
16325 1082832 }
16326
16327
2/2
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 1082832 times.
1263304 for(int32_t k=0; k<6; k++)
16328 {
16329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1082832 times.
1082832 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16330 {
16331 return qe_invalid;
16332 }
16333 1082832 }
16334 180472 }
16335
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16336 {
16337 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16338 {
16339 return qe_invalid;
16340 }
16341
16342 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16343 {
16344 return qe_invalid;
16345 }
16346
16347 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16348 {
16349 return qe_invalid;
16350 }
16351
16352 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16353
16354 {
16355 return qe_invalid;
16356 }
16357 }
16358
16359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
187336 if((Header->zelda_version == 0x192)&&(Header->build>149))
16360 {
16361 for(int32_t k=0; k<6; k++)
16362 {
16363 if(!p_getc(&tempbyte,f,true)) //layerxsize
16364 {
16365 return qe_invalid;
16366 }
16367 }
16368
16369 for(int32_t k=0; k<6; k++)
16370 {
16371 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16372 {
16373 return qe_invalid;
16374 }
16375 }
16376
16377 for(int32_t k=0; k<6; k++)
16378 {
16379 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16380 {
16381 return qe_invalid;
16382 }
16383 }
16384
16385 for(int32_t k=0; k<6; k++)
16386 {
16387 if(!p_getc(&tempbyte,f,true)) //layerysize
16388 {
16389 return qe_invalid;
16390 }
16391 }
16392
16393 for(int32_t k=0; k<6; k++)
16394 {
16395 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16396 {
16397 return qe_invalid;
16398 }
16399 }
16400
16401 for(int32_t k=0; k<6; k++)
16402 {
16403 if(!p_getc(&tempbyte,f,true)) //layerydelay
16404 {
16405 return qe_invalid;
16406 }
16407 }
16408 }
16409
16410
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16411 {
16412
2/2
✓ Branch 0 taken 1082832 times.
✓ Branch 1 taken 180472 times.
1263304 for(int32_t k=0; k<6; k++)
16413 {
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1082832 times.
1082832 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16415 {
16416 return qe_invalid;
16417 }
16418 1082832 }
16419 180472 }
16420
16421
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16422 {
16423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180472 if((Header->zelda_version == 0x192)&&(Header->build>153))
16424 {
16425 if(!p_getc(&padding,f,true))
16426 {
16427 return qe_invalid;
16428 }
16429 }
16430
16431
1/2
✓ Branch 0 taken 180472 times.
✗ Branch 1 not taken.
180472 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16432 {
16433 return qe_invalid;
16434 }
16435 180472 }
16436
16437
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16438 {
16439 6864 extras=15;
16440 6864 }
16441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180472 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16442 {
16443 extras=11;
16444 }
16445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180472 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16446 {
16447 extras=32;
16448 }
16449
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180472 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16450 {
16451 extras=64;
16452 }
16453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
180472 else if(Header->zelda_version < 0x193)
16454 {
16455 extras=62;
16456 }
16457 else
16458
16459 {
16460 180472 extras=0;
16461 }
16462
16463
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 187336 times.
290296 for(int32_t k=0; k<extras; k++)
16464 {
16465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16466 {
16467 return qe_invalid;
16468 }
16469 102960 }
16470
16471
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16472 //if (version>3)
16473 {
16474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16475 {
16476 return qe_invalid;
16477 }
16478
16479
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16480 {
16481 return qe_invalid;
16482 }
16483 152592 }
16484 else
16485 {
16486 34744 temp_mapscr->nextmap=0;
16487 34744 temp_mapscr->nextscr=0;
16488 }
16489
16490
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16491 {
16492 6864 secretcombos=20;
16493 6864 }
16494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180472 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16495 {
16496 secretcombos=256;
16497 }
16498 else
16499 {
16500 180472 secretcombos=128;
16501 }
16502
16503
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16504 {
16505
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16506 {
16507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16508 {
16509 return qe_invalid;
16510 }
16511
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16513 {
16514 137280 temp_mapscr->secretcombo[k]=tempbyte;
16515 137280 }
16516 137280 }
16517 6864 }
16518 else
16519 {
16520
2/2
✓ Branch 0 taken 23100416 times.
✓ Branch 1 taken 180472 times.
23280888 for(int32_t k=0; k<128; k++)
16521 {
16522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23100416 times.
23100416 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16523 {
16524 return qe_invalid;
16525 }
16526
16527 23100416 }
16528 }
16529
16530
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16531 {
16532
2/2
✓ Branch 0 taken 23100416 times.
✓ Branch 1 taken 180472 times.
23280888 for(int32_t k=0; k<128; k++)
16533 {
16534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23100416 times.
23100416 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16535 {
16536 return qe_invalid;
16537 }
16538 23100416 }
16539
16540
2/2
✓ Branch 0 taken 23100416 times.
✓ Branch 1 taken 180472 times.
23280888 for(int32_t k=0; k<128; k++)
16541 {
16542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23100416 times.
23100416 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16543 {
16544 return qe_invalid;
16545 }
16546 23100416 }
16547 180472 }
16548
16549
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16550 {
16551 if(!p_getc(&padding,f,true))
16552 {
16553 return qe_invalid;
16554 }
16555 }
16556
16557 187336 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16558
16559
2/2
✓ Branch 0 taken 32971136 times.
✓ Branch 1 taken 187336 times.
33158472 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16560 {
16561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32971136 times.
32971136 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16562 {
16563 return qe_invalid;
16564 }
16565 32971136 }
16566
16567
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 187336 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16568 {
16569 if(!p_getc(&padding,f,true))
16570 {
16571 return qe_invalid;
16572 }
16573
16574 if(!p_getc(&padding,f,true))
16575 {
16576 return qe_invalid;
16577 }
16578 }
16579
16580
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16581 {
16582
2/2
✓ Branch 0 taken 31763072 times.
✓ Branch 1 taken 180472 times.
31943544 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16583 {
16584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31763072 times.
31763072 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16585 {
16586 return qe_invalid;
16587 }
16588
16589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31763072 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31763072 if((Header->zelda_version == 0x192)&&(Header->build<24))
16590 {
16591 if(!p_getc(&tempbyte,f,true))
16592 {
16593 return qe_invalid;
16594 }
16595
16596 if(!p_getc(&tempbyte,f,true))
16597 {
16598 return qe_invalid;
16599 }
16600
16601 if(!p_getc(&tempbyte,f,true))
16602 {
16603 return qe_invalid;
16604 }
16605 }
16606 31763072 }
16607 180472 }
16608
16609
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 180472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16610 {
16611
2/2
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 31763072 times.
31943544 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16612 {
16613
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31763072 times.
31763072 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16615 {
16616 return qe_invalid;
16617 }
16618 31763072 }
16619 180472 }
16620
16621
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16622 {
16623 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16624 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16625 6864 }
16626
16627
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16628 {
16629 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16630 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16631 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16632 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16633 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16634 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16635 6864 }
16636
16637
3/6
✓ Branch 0 taken 180472 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180472 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
187336 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16638 {
16639
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16640 {
16641
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16642 {
16643 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16644 {
16645 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16646 }
16647 }
16648 else
16649 {
16650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16651 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16652 {
16653 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16654 1208064 }
16655
16656 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16657 }
16658
16659 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16660 1208064 }
16661 6864 }
16662
16663 /*if(version>12)
16664 {
16665 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16666 {
16667 return qe_invalid;
16668 }
16669 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16670 {
16671 return qe_invalid;
16672 }
16673 }*/
16674
16675
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version>4)
16676 {
16677
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16678 {
16679 return qe_invalid;
16680 }
16681 152592 }
16682 else
16683 {
16684 34744 temp_mapscr->screen_midi = -1;
16685 }
16686
16687
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version>=17)
16688 {
16689
1/2
✓ Branch 0 taken 152592 times.
✗ Branch 1 not taken.
152592 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16690 {
16691 return qe_invalid;
16692 }
16693 152592 }
16694 else
16695 {
16696 34744 temp_mapscr->lens_layer = llNORMAL;
16697 }
16698
16699
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 152592 times.
187336 if(version>6)
16700 {
16701 dword bits;
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152592 times.
152592 if(!p_igetl(&bits,f,true))
16703 {
16704 return qe_invalid;
16705 }
16706
16707 int32_t m;
16708 float tempfloat;
16709 word tempw;
16710 152592 temp_mapscr->ffcCountMarkDirty();
16711
16712
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 4882944 times.
5035536 for(m=0; m<32; m++)
16713 {
16714 4882944 ffcdata& tempffc = temp_mapscr->ffcs[m];
16715 4882944 tempffc.clear();
16716
2/2
✓ Branch 0 taken 4859961 times.
✓ Branch 1 taken 22983 times.
4882944 if((bits>>m)&1)
16717 {
16718
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(!p_igetw(&tempw,f,true))
16719 {
16720 return qe_invalid;
16721 }
16722 22983 tempffc.setData(tempw);
16723
16724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&(tempffc.cset),f,true))
16725 {
16726 return qe_invalid;
16727 }
16728
16729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetw(&(tempffc.delay),f,true))
16730 {
16731 return qe_invalid;
16732 }
16733
16734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(version < 9)
16735 {
16736 if(!p_igetf(&tempfloat,f,true))
16737 {
16738 return qe_invalid;
16739 }
16740
16741 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16742
16743 if(!p_igetf(&tempfloat,f,true))
16744 {
16745 return qe_invalid;
16746 }
16747
16748 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16749
16750 if(!p_igetf(&tempfloat,f,true))
16751 {
16752 return qe_invalid;
16753 }
16754
16755 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16756
16757 if(!p_igetf(&tempfloat,f,true))
16758 {
16759 return qe_invalid;
16760 }
16761
16762 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16763
16764 if(!p_igetf(&tempfloat,f,true))
16765 {
16766 return qe_invalid;
16767 }
16768
16769 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16770
16771 if(!p_igetf(&tempfloat,f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16777 }
16778 else
16779 {
16780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetzf(&(tempffc.x),f,true))
16781 {
16782 return qe_invalid;
16783 }
16784
16785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetzf(&(tempffc.y),f,true))
16786 {
16787 return qe_invalid;
16788 }
16789
16790
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(!p_igetzf(&(tempffc.vx),f,true))
16791 {
16792 return qe_invalid;
16793 }
16794
16795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetzf(&(tempffc.vy),f,true))
16796 {
16797 return qe_invalid;
16798 }
16799
16800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetzf(&(tempffc.ax),f,true))
16801 {
16802 return qe_invalid;
16803 }
16804
16805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetzf(&(tempffc.ay),f,true))
16806 {
16807 return qe_invalid;
16808 }
16809 }
16810
16811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&(tempffc.link),f,true))
16812 {
16813 return qe_invalid;
16814 }
16815
16816
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(version>7)
16817 {
16818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&tempbyte,f,true))
16819 {
16820 return qe_invalid;
16821 }
16822
16823 22983 tempffc.hxsz = (tempbyte&0x3F)+1;
16824 22983 tempffc.txsz = (tempbyte>>6)+1;
16825
16826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&tempbyte,f,true))
16827 {
16828 return qe_invalid;
16829 }
16830
16831 22983 tempffc.hysz = (tempbyte&0x3F)+1;
16832 22983 tempffc.tysz = (tempbyte>>6)+1;
16833
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.flags),f,true))
16835 {
16836 return qe_invalid;
16837 }
16838 22983 }
16839 else
16840 {
16841 tempffc.hxsz=16;
16842 tempffc.hysz=16;
16843 tempffc.txsz=1;
16844 tempffc.tysz=1;
16845 tempffc.flags=0;
16846 }
16847
16848 22983 tempffc.updateSolid();
16849
16850
16851
4/6
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20963 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20963 times.
22983 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16852 {
16853 tempffc.flags|=ffIGNOREHOLDUP;
16854 }
16855
16856
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(version>9)
16857 {
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetw(&(tempffc.script),f,true))
16859 {
16860 return qe_invalid;
16861 }
16862 22983 }
16863 else
16864 {
16865 tempffc.script=0;
16866 }
16867
16868
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(version>10)
16869 {
16870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[0]),f,true))
16871 {
16872 return qe_invalid;
16873 }
16874
16875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[1]),f,true))
16876 {
16877 return qe_invalid;
16878 }
16879
16880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[2]),f,true))
16881 {
16882 return qe_invalid;
16883 }
16884
16885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[3]),f,true))
16886 {
16887 return qe_invalid;
16888 }
16889
16890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[4]),f,true))
16891 {
16892 return qe_invalid;
16893 }
16894
16895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[5]),f,true))
16896 {
16897 return qe_invalid;
16898 }
16899
16900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[6]),f,true))
16901 {
16902 return qe_invalid;
16903 }
16904
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_igetl(&(tempffc.initd[7]),f,true))
16906 {
16907 return qe_invalid;
16908 }
16909
16910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&(tempbyte),f,true))
16911 {
16912 return qe_invalid;
16913 }
16914
16915 22983 tempffc.inita[0]=tempbyte*10000;
16916
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22983 times.
22983 if(!p_getc(&(tempbyte),f,true))
16918 {
16919 return qe_invalid;
16920 }
16921
16922 22983 tempffc.inita[1]=tempbyte*10000;
16923 22983 }
16924 else
16925 {
16926 tempffc.inita[0] = 10000;
16927 tempffc.inita[1] = 10000;
16928 }
16929
16930 22983 tempffc.initialized = false;
16931
16932
1/2
✓ Branch 0 taken 22983 times.
✗ Branch 1 not taken.
22983 if(version <= 11)
16933 {
16934 fixffcs=true;
16935 }
16936 22983 }
16937 4882944 }
16938
16939 152592 }
16940
16941 //add in the new whistle flags
16942
2/2
✓ Branch 0 taken 152592 times.
✓ Branch 1 taken 34744 times.
187336 if(version<13)
16943 {
16944
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
16945 {
16946 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16947 12 }
16948 34744 }
16949
16950 // for(int32_t m=0; m<32; m++)
16951 // {
16952 // // ffcScriptData used to be part of mapscr, and this was handled just above
16953 // ffcScriptData[m].a[0] = 10000;
16954 // ffcScriptData[m].a[1] = 10000;
16955 // }
16956
16957 //2.55 starts here
16958
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 173600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187336 if ( version >= 19 && Header->zelda_version > 0x253 )
16959 {
16960
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16961 {
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16963 {
16964 return qe_invalid;
16965 }
16966 137360 }
16967
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16968 {
16969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16970 {
16971 return qe_invalid;
16972 }
16973 137360 }
16974
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16977 {
16978 return qe_invalid;
16979 }
16980 137360 }
16981
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16982 {
16983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16984 {
16985 return qe_invalid;
16986 }
16987 137360 }
16988 13736 }
16989
3/4
✓ Branch 0 taken 173600 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173600 times.
187336 if ( version < 19 && Header->zelda_version > 0x253 )
16990 {
16991 for ( int32_t q = 0; q < 10; q++ )
16992 {
16993 temp_mapscr->npcstrings[q] = 0;
16994 temp_mapscr->new_items[q] = 0;
16995 temp_mapscr->new_item_x[q] = 0;
16996 temp_mapscr->new_item_y[q] = 0;
16997 }
16998 }
16999
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 173600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187336 if ( version >= 20 && Header->zelda_version > 0x253 )
17000 {
17001
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17002 {
17003 return qe_invalid;
17004 }
17005
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17006 {
17007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17008 {
17009 return qe_invalid;
17010 }
17011 109888 }
17012 13736 }
17013
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 173600 times.
187336 if ( version < 20 )
17014 {
17015 173600 temp_mapscr->script = 0;
17016
2/2
✓ Branch 0 taken 1388800 times.
✓ Branch 1 taken 173600 times.
1562400 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17017 173600 }
17018
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 173600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187336 if ( version >= 21 && Header->zelda_version > 0x253 )
17019 {
17020
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17021 {
17022 return qe_invalid;
17023 }
17024 13736 }
17025
2/2
✓ Branch 0 taken 173600 times.
✓ Branch 1 taken 13736 times.
187336 if ( version < 21 )
17026 {
17027 173600 temp_mapscr->preloadscript = 0;
17028 173600 }
17029 //all builds with version > 20 need this. -Z
17030 187336 temp_mapscr->ffcswaitdraw = 0;
17031
17032
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 173600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
187336 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17033 {
17034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17035 {
17036 return qe_invalid;
17037 }
17038
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17039 {
17040 return qe_invalid;
17041 }
17042 13736 }
17043
2/2
✓ Branch 0 taken 173600 times.
✓ Branch 1 taken 13736 times.
187336 if ( version < 22 )
17044 {
17045 173600 temp_mapscr->hidelayers = 0;
17046 173600 temp_mapscr->hidescriptlayers = 0;
17047 173600 }
17048
17049 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17050 //May be any version before 2.11. -Z
17051 /* --not the roar, the HIT SFX
17052 if ( Header->zelda_version <= 0x210 )
17053 {
17054 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17055 {
17056 temp_mapscr->bosssfx = WAV_ROAR;
17057 }
17058 }
17059 */
17060
17061 187336 return 0;
17062 187336 }
17063 200120 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17064 {
17065
2/2
✓ Branch 0 taken 187336 times.
✓ Branch 1 taken 12784 times.
200120 if(version < 23)
17066 {
17067 187336 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17068
1/2
✓ Branch 0 taken 187336 times.
✗ Branch 1 not taken.
187336 if(ret) return ret;
17069 187336 }
17070 else
17071 {
17072
1/2
✓ Branch 0 taken 12784 times.
✗ Branch 1 not taken.
12784 if(!p_getc(&(temp_mapscr->valid),f,true))
17073 return qe_invalid;
17074
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 7528 times.
12784 if(!(temp_mapscr->valid & mVALID))
17075 7528 return 0; //Empty screen
17076 uint32_t scr_has_flags;
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5256 times.
5256 if(!p_igetl(&scr_has_flags,f,true))
17078 return qe_invalid;
17079
17080
2/2
✓ Branch 0 taken 5211 times.
✓ Branch 1 taken 45 times.
5256 if(scr_has_flags & SCRHAS_ROOMDATA)
17081 {
17082
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
17083 return qe_invalid;
17084
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
17085 return qe_invalid;
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
17087 return qe_invalid;
17088
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17089 return qe_invalid;
17090 45 }
17091
2/2
✓ Branch 0 taken 5175 times.
✓ Branch 1 taken 81 times.
5256 if(scr_has_flags & SCRHAS_ITEM)
17092 {
17093
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
17094 return qe_invalid;
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17096 return qe_invalid;
17097
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
17098 return qe_invalid;
17099
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
17100 return qe_invalid;
17101 81 }
17102
2/2
✓ Branch 0 taken 4964 times.
✓ Branch 1 taken 292 times.
5256 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17103 {
17104
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17105 return qe_invalid;
17106 292 }
17107
2/2
✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 198 times.
5256 if(scr_has_flags & SCRHAS_TWARP)
17108 {
17109
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17110 {
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17112 return qe_invalid;
17113 792 }
17114
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17115 {
17116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17117 return qe_invalid;
17118 792 }
17119
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17120 {
17121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17122 return qe_invalid;
17123 792 }
17124
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17125 return qe_invalid;
17126 198 }
17127
2/2
✓ Branch 0 taken 5138 times.
✓ Branch 1 taken 118 times.
5256 if(scr_has_flags & SCRHAS_SWARP)
17128 {
17129
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17130 {
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17132 return qe_invalid;
17133 472 }
17134
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17135 {
17136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17137 return qe_invalid;
17138 472 }
17139
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17140 {
17141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17142 return qe_invalid;
17143 472 }
17144
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17145 return qe_invalid;
17146
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17147 return qe_invalid;
17148 118 }
17149
2/2
✓ Branch 0 taken 4960 times.
✓ Branch 1 taken 296 times.
5256 if(scr_has_flags & SCRHAS_WARPRET)
17150 {
17151
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17152 {
17153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17154 return qe_invalid;
17155 1184 }
17156
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17157 {
17158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17159 return qe_invalid;
17160 1184 }
17161
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17162 return qe_invalid;
17163
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17164 return qe_invalid;
17165 296 }
17166
2/2
✓ Branch 0 taken 1034 times.
✓ Branch 1 taken 4222 times.
5256 if(scr_has_flags & SCRHAS_LAYERS)
17167 {
17168
2/2
✓ Branch 0 taken 6204 times.
✓ Branch 1 taken 1034 times.
7238 for(int32_t k=0; k<6; k++)
17169 {
17170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6204 times.
6204 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17171 return qe_invalid;
17172 6204 }
17173
2/2
✓ Branch 0 taken 6204 times.
✓ Branch 1 taken 1034 times.
7238 for(int32_t k=0; k<6; k++)
17174 {
17175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6204 times.
6204 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17176 return qe_invalid;
17177 6204 }
17178
2/2
✓ Branch 0 taken 6204 times.
✓ Branch 1 taken 1034 times.
7238 for(int32_t k=0; k<6; k++)
17179 {
17180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6204 times.
6204 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17181 return qe_invalid;
17182 6204 }
17183
1/2
✓ Branch 0 taken 1034 times.
✗ Branch 1 not taken.
1034 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17184 return qe_invalid;
17185
1/2
✓ Branch 0 taken 1034 times.
✗ Branch 1 not taken.
1034 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17186 return qe_invalid;
17187 1034 }
17188 else
17189 {
17190
2/2
✓ Branch 0 taken 25332 times.
✓ Branch 1 taken 4222 times.
29554 for(int32_t k=0; k<6; k++)
17191 {
17192 25332 temp_mapscr->layeropacity[k] = 255;
17193 25332 }
17194 }
17195
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(scr_has_flags & SCRHAS_MAZE)
17196 {
17197 for(int32_t k=0; k<4; k++)
17198 {
17199 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17200 return qe_invalid;
17201 }
17202 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17203 return qe_invalid;
17204 }
17205
2/2
✓ Branch 0 taken 5152 times.
✓ Branch 1 taken 104 times.
5256 if(scr_has_flags & SCRHAS_D_S_U)
17206 {
17207
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17208 return qe_invalid;
17209
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17210 {
17211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17212 return qe_invalid;
17213 416 }
17214
17215
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&(temp_mapscr->stairx),f,true))
17216 return qe_invalid;
17217
17218
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&(temp_mapscr->stairy),f,true))
17219 return qe_invalid;
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17221 return qe_invalid;
17222
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&(temp_mapscr->undercset),f,true))
17223 return qe_invalid;
17224 104 }
17225
2/2
✓ Branch 0 taken 4895 times.
✓ Branch 1 taken 361 times.
5256 if(scr_has_flags & SCRHAS_FLAGS)
17226 {
17227
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags),f,true))
17228 return qe_invalid;
17229
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags2),f,true))
17230 return qe_invalid;
17231
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags3),f,true))
17232 return qe_invalid;
17233
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags4),f,true))
17234 return qe_invalid;
17235
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags5),f,true))
17236 return qe_invalid;
17237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361 times.
361 if(!p_getc(&(temp_mapscr->flags6),f,true))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags7),f,true))
17240 return qe_invalid;
17241
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags8),f,true))
17242 return qe_invalid;
17243
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags9),f,true))
17244 return qe_invalid;
17245
1/2
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
361 if(!p_getc(&(temp_mapscr->flags10),f,true))
17246 return qe_invalid;
17247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361 times.
361 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17248 return qe_invalid;
17249 361 }
17250
2/2
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 318 times.
5256 if(scr_has_flags & SCRHAS_ENEMY)
17251 {
17252
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17253 {
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17255 return qe_invalid;
17256
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17257 temp_mapscr->enemy[k] = 0;
17258 3180 }
17259
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17260 return qe_invalid;
17261 318 }
17262
2/2
✓ Branch 0 taken 5225 times.
✓ Branch 1 taken 31 times.
5256 if(scr_has_flags & SCRHAS_CARRY)
17263 {
17264
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17265 return qe_invalid;
17266
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17267 return qe_invalid;
17268
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17269 return qe_invalid;
17270
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17271 return qe_invalid;
17272 31 }
17273
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 24 times.
5256 if(scr_has_flags & SCRHAS_SCRIPT)
17274 {
17275
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17276 return qe_invalid;
17277
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17278 return qe_invalid;
17279
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17280 {
17281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17282 return qe_invalid;
17283 192 }
17284 24 }
17285
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(scr_has_flags & SCRHAS_UNUSED)
17286 {
17287 for ( int32_t q = 0; q < 10; q++ )
17288 {
17289 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17290 return qe_invalid;
17291 }
17292 for ( int32_t q = 0; q < 10; q++ )
17293 {
17294 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17295 return qe_invalid;
17296 }
17297 for ( int32_t q = 0; q < 10; q++ )
17298 {
17299 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17300 return qe_invalid;
17301 }
17302 for ( int32_t q = 0; q < 10; q++ )
17303 {
17304 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17305 return qe_invalid;
17306 }
17307 }
17308
2/2
✓ Branch 0 taken 4903 times.
✓ Branch 1 taken 353 times.
5256 if(scr_has_flags & SCRHAS_SECRETS)
17309 {
17310
2/2
✓ Branch 0 taken 45184 times.
✓ Branch 1 taken 353 times.
45537 for(int32_t k=0; k<128; k++)
17311 {
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45184 times.
45184 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17313 return qe_invalid;
17314 45184 }
17315
2/2
✓ Branch 0 taken 45184 times.
✓ Branch 1 taken 353 times.
45537 for(int32_t k=0; k<128; k++)
17316 {
17317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45184 times.
45184 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17318 return qe_invalid;
17319 45184 }
17320
2/2
✓ Branch 0 taken 45184 times.
✓ Branch 1 taken 353 times.
45537 for(int32_t k=0; k<128; k++)
17321 {
17322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45184 times.
45184 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17323 return qe_invalid;
17324 45184 }
17325 353 }
17326
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2397 times.
5256 if(scr_has_flags & SCRHAS_COMBOFLAG)
17327 {
17328
2/2
✓ Branch 0 taken 421872 times.
✓ Branch 1 taken 2397 times.
424269 for(int32_t k=0; k<176; ++k)
17329 {
17330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421872 times.
421872 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17331 return qe_invalid;
17332 421872 }
17333
2/2
✓ Branch 0 taken 421872 times.
✓ Branch 1 taken 2397 times.
424269 for(int32_t k=0; k<176; ++k)
17334 {
17335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421872 times.
421872 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17336 return qe_invalid;
17337 421872 }
17338
2/2
✓ Branch 0 taken 421872 times.
✓ Branch 1 taken 2397 times.
424269 for(int32_t k=0; k<176; ++k)
17339 {
17340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421872 times.
421872 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17341 return qe_invalid;
17342 421872 }
17343 2397 }
17344
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(scr_has_flags & SCRHAS_MISC)
17345 {
17346
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_igetw(&(temp_mapscr->color),f,true))
17347 return qe_invalid;
17348
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17349 return qe_invalid;
17350
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17351 return qe_invalid;
17352
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17353 return qe_invalid;
17354
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17355 return qe_invalid;
17356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5256 times.
5256 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17357 return qe_invalid;
17358
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17359 return qe_invalid;
17360
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17361 return qe_invalid;
17362
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17363 return qe_invalid;
17364 5256 }
17365 else
17366 {
17367 temp_mapscr->screen_midi = -1;
17368 temp_mapscr->csensitive = 1;
17369 }
17370 //FFC
17371 5256 bool old_ff = version < 25;
17372 5256 dword bits = 0;
17373 5256 word numffc = 32;
17374
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 5234 times.
5256 if(old_ff)
17375 {
17376
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&bits,f,true))
17377 return qe_invalid;
17378 22 }
17379 else
17380 {
17381
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(!p_igetw(&numffc,f,true))
17382 return qe_invalid;
17383 }
17384 byte tempbyte;
17385 word tempw;
17386
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5235 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
5256 static ffcdata nil_ffc;
17387 5256 temp_mapscr->ffcCountMarkDirty();
17388
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 6862 times.
12118 for(word m = 0; m < numffc; ++m)
17389 {
17390
1/2
✓ Branch 0 taken 6862 times.
✗ Branch 1 not taken.
6862 ffcdata& tempffc = (m < MAXFFCS)
17391 6862 ? temp_mapscr->ffcs[m]
17392 : nil_ffc; //sanity
17393 6862 tempffc.clear();
17394
3/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 6158 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
6862 if(old_ff && !(bits & (1<<m))) continue;
17395
17396
1/2
✓ Branch 0 taken 6158 times.
✗ Branch 1 not taken.
6158 if(!p_igetw(&tempw,f,true))
17397 return qe_invalid;
17398
3/4
✓ Branch 0 taken 6158 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5193 times.
6158 if(!old_ff && !tempw) //empty ffc, nothing more to load
17399 5193 continue;
17400 965 tempffc.setData(tempw);
17401
17402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17403 return qe_invalid;
17404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17405 return qe_invalid;
17406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17407 return qe_invalid;
17408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17409 return qe_invalid;
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17411 return qe_invalid;
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17413 return qe_invalid;
17414
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17415 return qe_invalid;
17416
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17417 return qe_invalid;
17418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17419 return qe_invalid;
17420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17421 {
17422 if(!p_getc(&tempbyte,f,true))
17423 return qe_invalid;
17424 tempffc.hxsz = (tempbyte&0x3F)+1;
17425 tempffc.txsz = (tempbyte>>6)+1;
17426 if(!p_getc(&tempbyte,f,true))
17427 return qe_invalid;
17428 tempffc.hysz = (tempbyte&0x3F)+1;
17429 tempffc.tysz = (tempbyte>>6)+1;
17430 }
17431 else
17432 {
17433
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17434 return qe_invalid;
17435
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17436 return qe_invalid;
17437
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17438 return qe_invalid;
17439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17440 return qe_invalid;
17441 }
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17443 return qe_invalid;
17444 965 tempffc.updateSolid();
17445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17446 return qe_invalid;
17447
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17448 {
17449
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17450 return qe_invalid;
17451 7720 }
17452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17453 return qe_invalid;
17454 965 tempffc.inita[0]=tempbyte*10000;
17455
17456
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17457 return qe_invalid;
17458 965 tempffc.inita[1]=tempbyte*10000;
17459
17460 965 tempffc.initialized = false;
17461 965 }
17462
2/2
✓ Branch 0 taken 665906 times.
✓ Branch 1 taken 5256 times.
671162 for(word m = numffc; m < MAXFFCS; ++m)
17463 {
17464 665906 temp_mapscr->ffcs[m].clear();
17465 665906 }
17466 //END FFC
17467 }
17468 192592 return 0;
17469 200120 }
17470
17471
17472 108 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17473 {
17474 108 int32_t scr=0;
17475
17476 108 word version=0;
17477 dword dummy;
17478 int32_t screens_to_read;
17479
17480 108 mapscr temp_mapscr;
17481 zcmap temp_map;
17482 word temp_map_count;
17483 dword section_size;
17484
17485
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17486 {
17487 4 screens_to_read=MAPSCRS192b136;
17488 4 }
17489 else
17490 {
17491 104 screens_to_read=MAPSCRS;
17492 }
17493
17494
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version > 0x192)
17495 {
17496 //section version info
17497
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&version,f,true))
17498 {
17499 return qe_invalid;
17500 }
17501
17502 104 FFCore.quest_format[vMaps] = version;
17503
17504 //al_trace("Maps version %d\n", version);
17505
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
17506 {
17507 return qe_invalid;
17508 }
17509
17510 //section size
17511
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&section_size,f,true))
17512 {
17513 return qe_invalid;
17514 }
17515
17516 //finally... section data
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_igetw(&temp_map_count,f,true))
17518 {
17519 return 5;
17520 }
17521 104 }
17522 else
17523 {
17524 4 temp_map_count=map_count;
17525 }
17526
17527
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
17529 {
17530 108 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17531 108 TheMaps.resize(_mapsSize);
17532
17533
2/2
✓ Branch 0 taken 201280 times.
✓ Branch 1 taken 108 times.
201388 for(int32_t i(0); i<_mapsSize; i++)
17534 201280 TheMaps[i].zero_memory();
17535
17536 // Used to be done for each screen
17537
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 108 times.
13932 for(int32_t i=0; i<MAXFFCS; i++)
17538 {
17539 13824 ffcScriptData[i].a[0] = 10000;
17540 13824 ffcScriptData[i].a[1] = 10000;
17541 13824 }
17542
17543 108 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17544 108 }
17545
17546 108 temp_mapscr.zero_memory();
17547
17548 108 memset(&temp_map, 0, sizeof(zcmap));
17549 108 temp_map.scrResWidth = 256;
17550 108 temp_map.scrResHeight = 224;
17551 108 temp_map.tileWidth = 16;
17552 108 temp_map.tileHeight = 11;
17553 108 temp_map.viewWidth = 256;
17554 108 temp_map.viewHeight = 176;
17555 108 temp_map.viewX = 0;
17556 108 temp_map.viewY = 64;
17557 108 temp_map.subaWidth = 256;
17558 108 temp_map.subaHeight = 168;
17559 108 temp_map.subaTrans = false;
17560 108 temp_map.subpWidth = 256;
17561 108 temp_map.subpHeight = 56;
17562 108 temp_map.subpTrans = false;
17563
4/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1480 times.
✓ Branch 3 taken 108 times.
1588 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17564 {
17565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if(keepdata==true) //!TODO Trim fully
17566 {
17567 1480 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17568 1480 }
17569 1480 byte valid=1;
17570
2/2
✓ Branch 0 taken 1379 times.
✓ Branch 1 taken 101 times.
1480 if(version > 22)
17571 {
17572
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(!p_getc(&valid,f,true))
17573 return qe_invalid;
17574 101 }
17575
2/2
✓ Branch 0 taken 201072 times.
✓ Branch 1 taken 1480 times.
202552 for(int32_t j=0; j<screens_to_read; j++)
17576 {
17577 201072 scr=i*MAPSCRS+j;
17578 201072 clear_screen(&temp_mapscr);
17579
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 200120 times.
201072 if(valid)
17580 200120 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17581
17582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201072 times.
201072 if(keepdata==true)
17583 {
17584 201072 TheMaps[scr] = temp_mapscr;
17585 201072 }
17586 201072 }
17587
17588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if(keepdata==true)
17589 {
17590
3/6
✓ Branch 0 taken 1428 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1428 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17591 {
17592 52 int32_t index = (i*MAPSCRS+132);
17593
17594 52 TheMaps[index]=TheMaps[index-1];
17595
17596 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17597 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17598 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17599
17600
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17601 {
17602 156 scr=i*MAPSCRS+j;
17603
17604 156 TheMaps[scr].zero_memory();
17605 156 TheMaps[scr].valid = mVERSION;
17606 156 TheMaps[scr].screen_midi = -1;
17607 156 TheMaps[scr].csensitive = 1;
17608 156 }
17609 52 }
17610
17611
3/6
✓ Branch 0 taken 1428 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1428 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17612 {
17613
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17614 {
17615 7072 scr=i*MAPSCRS+j;
17616 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17617
17618
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17619 {
17620 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17621 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17622 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17623 905216 }
17624 7072 }
17625 52 }
17626 1480 }
17627 1480 }
17628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata)
17629 {
17630 108 map_count = temp_map_count;
17631 108 }
17632 108 clear_screen(&temp_mapscr);
17633 108 return 0;
17634 108 }
17635
17636
17637 86 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17638 {
17639 86 reset_combo_animations();
17640 86 reset_combo_animations2();
17641
17642 86 init_combo_classes();
17643
17644 // combos
17645 86 word combos_used=0;
17646 int32_t dummy;
17647 byte padding;
17648 86 newcombo temp_combo;
17649 //word section_cversion=0;
17650
17651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(keepdata==true)
17652 {
17653
2/2
✓ Branch 0 taken 5614080 times.
✓ Branch 1 taken 86 times.
5614166 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17654 5614080 combobuf[q].clear();
17655 86 }
17656
17657 // if(version > 0x192)
17658 // {
17659 // //section version info
17660 // if(!p_igetw(&section_version,f,true))
17661 // {
17662 // return qe_invalid;
17663 // }
17664
17665 // FFCore.quest_format[vCombos] = section_version;
17666
17667 // //al_trace("Combos version %d\n", section_version);
17668 // if(!p_igetw(&section_cversion,f,true))
17669 // {
17670 // return qe_invalid;
17671 // }
17672
17673 // //section size
17674 // if(!p_igetl(&dummy,f,true))
17675 // {
17676 // return qe_invalid;
17677 // }
17678 // }
17679
17680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(version < 0x174)
17681 {
17682 combos_used=1024;
17683 }
17684
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 82 times.
86 else if(version < 0x191)
17685 {
17686 4 combos_used=2048;
17687 4 }
17688 else
17689 {
17690
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(!p_igetw(&combos_used,f,true))
17691 {
17692 return qe_invalid;
17693 }
17694 }
17695
17696 //finally... section data
17697
2/2
✓ Branch 0 taken 516169 times.
✓ Branch 1 taken 86 times.
516255 for(int32_t i=0; i<combos_used; i++)
17698 {
17699 516169 temp_combo.clear();
17700
17701
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447285 times.
516169 if ( section_version >= 11 )
17702 {
17703
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17704 {
17705 return qe_invalid;
17706 }
17707 68884 }
17708 else
17709 {
17710
1/2
✓ Branch 0 taken 447285 times.
✗ Branch 1 not taken.
447285 if(!p_igetw(&temp_combo.tile,f,true))
17711 {
17712 return qe_invalid;
17713 }
17714 }
17715 516169 temp_combo.o_tile = temp_combo.tile;
17716
1/2
✓ Branch 0 taken 516169 times.
✗ Branch 1 not taken.
516169 if(!p_getc(&temp_combo.flip,f,true))
17717 {
17718 return qe_invalid;
17719 }
17720
17721
1/2
✓ Branch 0 taken 516169 times.
✗ Branch 1 not taken.
516169 if(!p_getc(&temp_combo.walk,f,true))
17722 {
17723 return qe_invalid;
17724 }
17725
17726
1/2
✓ Branch 0 taken 516169 times.
✗ Branch 1 not taken.
516169 if(!p_getc(&temp_combo.type,f,true))
17727 {
17728 return qe_invalid;
17729 }
17730
17731
1/2
✓ Branch 0 taken 516169 times.
✗ Branch 1 not taken.
516169 if(!p_getc(&temp_combo.csets,f,true))
17732 {
17733 return qe_invalid;
17734 }
17735
17736
2/2
✓ Branch 0 taken 507977 times.
✓ Branch 1 taken 8192 times.
516169 if(version < 0x193)
17737 {
17738
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17739 return qe_invalid;
17740
17741
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17742 return qe_invalid;
17743
17744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17745 {
17746
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17747 {
17748 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17749 {
17750 if(!p_getc(&padding,f,true))
17751 return qe_invalid;
17752 }
17753 }
17754 8192 }
17755 8192 }
17756
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 507977 times.
516169 if(version >= 0x192)
17757 {
17758
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(!p_getc(&temp_combo.frames,f,true))
17759 return qe_invalid;
17760
17761
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(!p_getc(&temp_combo.speed,f,true))
17762 return qe_invalid;
17763
17764
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(!p_igetw(&temp_combo.nextcombo,f,true))
17765 return qe_invalid;
17766
17767
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(!p_getc(&temp_combo.nextcset,f,true))
17768 return qe_invalid;
17769
17770 //Base flag
17771
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 398863 times.
507977 if(section_version>=3)
17772
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(!p_getc(&temp_combo.flag,f,true))
17773 return qe_invalid;
17774
17775
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 398863 times.
507977 if(section_version>=4)
17776 {
17777
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(!p_getc(&temp_combo.skipanim,f,true))
17778 return qe_invalid;
17779
17780
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(!p_igetw(&temp_combo.nexttimer,f,true))
17781 return qe_invalid;
17782 398863 }
17783
17784
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 398863 times.
507977 if(section_version>=5)
17785
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(!p_getc(&temp_combo.skipanimy,f,true))
17786 return qe_invalid;
17787
17788
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 398863 times.
507977 if(section_version>=6)
17789 {
17790
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(!p_getc(&temp_combo.animflags,f,true))
17791 return qe_invalid;
17792
17793
1/2
✓ Branch 0 taken 398863 times.
✗ Branch 1 not taken.
398863 if(section_version == 6)
17794 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17795 398863 }
17796
17797
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=8) //combo Attributes[4] and userflags.
17798 {
17799
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17800
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17801 return qe_invalid;
17802
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17803 return qe_invalid;
17804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(section_version >= 20)
17805
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17806 return qe_invalid;
17807 68884 }
17808
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439093 times.
507977 if(section_version>=10) //combo trigger flags
17809 {
17810
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17811
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17812 return qe_invalid;
17813 68884 }
17814
1/2
✓ Branch 0 taken 439093 times.
✗ Branch 1 not taken.
439093 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17815 {
17816 for ( int32_t q = 0; q < 2; q++ )
17817 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17818 return qe_invalid;
17819 }
17820
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version >= 9)
17821
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17822 return qe_invalid;
17823
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version >= 22)
17824
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17825 return qe_invalid;
17826
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 24)
17827 {
17828 if(!p_getc(&temp_combo.triggeritem,f,true))
17829 return qe_invalid;
17830 if(!p_getc(&temp_combo.trigtimer,f,true))
17831 return qe_invalid;
17832 }
17833
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 25)
17834 if(!p_getc(&temp_combo.trigsfx,f,true))
17835 return qe_invalid;
17836
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 27)
17837 if(!p_igetl(&temp_combo.trigchange,f,true))
17838 return qe_invalid;
17839
17840
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 29)
17841 {
17842 if(!p_igetw(&temp_combo.trigprox,f,true))
17843 return qe_invalid;
17844 if(!p_getc(&temp_combo.trigctr,f,true))
17845 return qe_invalid;
17846 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17847 return qe_invalid;
17848 }
17849
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 30)
17850 if(!p_getc(&temp_combo.triglbeam,f,true))
17851 return qe_invalid;
17852
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 31)
17853 {
17854 if(!p_getc(&temp_combo.trigcschange,f,true))
17855 return qe_invalid;
17856 if(!p_igetw(&temp_combo.spawnitem,f,true))
17857 return qe_invalid;
17858 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17859 return qe_invalid;
17860 if(!p_getc(&temp_combo.exstate,f,true))
17861 return qe_invalid;
17862 if(!p_igetl(&temp_combo.spawnip,f,true))
17863 return qe_invalid;
17864 if(!p_getc(&temp_combo.trigcopycat,f,true))
17865 return qe_invalid;
17866 }
17867
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(section_version >= 32)
17868 if(!p_getc(&temp_combo.trigcooldown,f,true))
17869 return qe_invalid;
17870
17871
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=12) //combo label
17872
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17873
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17874 68884 return qe_invalid;
17875
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=13) //attribytes[4]
17876
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17877
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17878 68884 return qe_invalid;
17879 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17880 * This fixes a poor implementation of a ->next flag bug thing.
17881 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17882 * there was a version bump a few weeks before a change that broke stuff.
17883 */
17884
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 439093 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
507977 if (section_version >= 13 && section_version < 21)
17885 {
17886 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17887 }
17888 //combo scripts
17889
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=14)
17890 {
17891
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17892 return qe_invalid;
17893
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17894
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17895 return qe_invalid;
17896 68884 }
17897 //al_trace("Read combo script data\n");
17898
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=15)
17899 {
17900
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17901
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17902
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17904 68884 }
17905
2/2
✓ Branch 0 taken 439093 times.
✓ Branch 1 taken 68884 times.
507977 if(section_version>=17) //attribytes[4]
17906 {
17907
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17908
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17909 return qe_invalid;
17910
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17911
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17912 return qe_invalid;
17913 68884 }
17914
17915
1/2
✓ Branch 0 taken 507977 times.
✗ Branch 1 not taken.
507977 if(version < 0x193)
17916 for(int32_t q=0; q<11; q++)
17917 if(!p_getc(&dummy,f,true))
17918 return qe_invalid;
17919 507977 }
17920
17921 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17922
3/6
✓ Branch 0 taken 398863 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398863 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
516169 if((version < 0x211)||((version == 0x211)&&(build<7)))
17923 {
17924
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17925 {
17926
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17927 {
17928 case 130:
17929 temp_combo.tile = 132;
17930 break;
17931
17932 case 131:
17933 temp_combo.tile = 133;
17934 break;
17935
17936 case 132:
17937 temp_combo.tile = 130;
17938 break;
17939
17940 case 133:
17941 temp_combo.tile = 131;
17942 break;
17943 }
17944 8192 }
17945 117306 }
17946
17947
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447285 times.
516169 if(section_version < 15)
17948 447285 temp_combo.o_tile = temp_combo.tile;
17949
17950
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447285 times.
516169 if(section_version<18) //upper bits for .walk
17951 447285 temp_combo.walk |= 0xF0;
17952
17953
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447285 times.
516169 if(section_version < 19)
17954
2/2
✓ Branch 0 taken 1789140 times.
✓ Branch 1 taken 447285 times.
2236425 for(int32_t q = 0; q < 4; ++q)
17955 2236425 temp_combo.attributes[q] *= 10000L;
17956
17957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(section_version < 23)
17958 {
17959
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 515785 times.
516169 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17960 {
17961 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17962 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17963 case cTRIGGERGENERIC: case cCSWITCH:
17964 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17965 384 }
17966 516169 }
17967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(section_version < 25)
17968 {
17969
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 513521 times.
516169 switch(temp_combo.type)
17970 {
17971 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2648 times.
2648 if(!(temp_combo.usrflags & cflag3))
17973 2648 temp_combo.attribytes[3] = WAV_DOOR;
17974 2648 temp_combo.usrflags &= ~cflag3;
17975 2648 break;
17976 }
17977 516169 }
17978
17979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(section_version < 26)
17980
2/2
✓ Branch 0 taken 515640 times.
✓ Branch 1 taken 529 times.
516698 if(temp_combo.type == cARMOS)
17981
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(temp_combo.usrflags & cflag1)
17982 temp_combo.usrflags |= cflag3;
17983
17984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(section_version < 27)
17985 {
17986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17987 temp_combo.trigchange = 1;
17988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17989 temp_combo.trigchange = -1;
17990 516169 else temp_combo.trigchange = 0;
17991 516169 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17992 516169 }
17993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 516169 times.
516169 if(section_version < 28)
17994 {
17995
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 514760 times.
516169 switch(temp_combo.type)
17996 {
17997 case cLOCKBLOCK: case cLOCKEDCHEST:
17998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1409 times.
1409 if(temp_combo.usrflags & cflag7)
17999 temp_combo.usrflags |= cflag8;
18000 1409 else temp_combo.usrflags &= ~cflag8;
18001 1409 temp_combo.usrflags &= ~cflag7;
18002 1409 break;
18003 }
18004
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 516100 times.
516169 switch(temp_combo.type)
18005 {
18006 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18007 69 temp_combo.attrishorts[2] = -1;
18008 69 temp_combo.usrflags |= cflag7;
18009 69 break;
18010 }
18011 516169 }
18012
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 447285 times.
516169 if(section_version < 20)
18013 {
18014 447285 temp_combo.genflags = 0;
18015
2/2
✓ Branch 0 taken 17519 times.
✓ Branch 1 taken 429766 times.
447285 switch(temp_combo.type)
18016 {
18017 case cPUSH_WAIT: case cPUSH_HEAVY:
18018 case cPUSH_HW: case cL_STATUE:
18019 case cR_STATUE: case cPUSH_HEAVY2:
18020 case cPUSH_HW2: case cPOUND:
18021 case cC_STATUE: case cMIRROR:
18022 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18023 case cMAGICPRISM: case cMAGICPRISM4:
18024 case cMAGICSPONGE: case cEYEBALL_A:
18025 case cEYEBALL_B: case cEYEBALL_4:
18026 case cBUSH: case cFLOWERS:
18027 case cLOCKBLOCK: case cLOCKBLOCK2:
18028 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18029 case cCHEST: case cCHEST2:
18030 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18031 case cBOSSCHEST: case cBOSSCHEST2:
18032 case cBUSHNEXT: case cBUSHTOUCHY:
18033 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18034 case cSIGNPOST: case cCSWITCHBLOCK:
18035 case cTORCH: case cTRIGGERGENERIC:
18036
1/2
✓ Branch 0 taken 17519 times.
✗ Branch 1 not taken.
17519 if(temp_combo.usrflags & cflag16)
18037 {
18038 temp_combo.genflags |= cflag1;
18039 temp_combo.usrflags &= ~cflag16;
18040 }
18041 17519 break;
18042 }
18043 447285 }
18044
18045
2/4
✓ Branch 0 taken 516169 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 516169 times.
516169 if(keepdata==true && i>=start_combo)
18046 {
18047 516169 combobuf[i] = temp_combo;
18048 516169 }
18049 516169 }
18050
18051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(keepdata==true)
18052 {
18053
3/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
86 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18054 {
18055
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18056 {
18057
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18058 {
18059 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18060 }
18061 261120 }
18062 4 }
18063
18064 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18065
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
86 if(version == 0x210 && !is_zquest())
18066 {
18067
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18068
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18069 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18070 5 }
18071
18072
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 9 times.
86 if(section_version<7)
18073 {
18074
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18075 {
18076
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18077 {
18078 case cSLASH:
18079 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18080 61 break;
18081
18082 case cSLASHITEM:
18083 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18084 62 break;
18085
18086 case cBUSH:
18087 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18088 28 break;
18089
18090 case cFLOWERS:
18091 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18092 10 break;
18093
18094 case cTALLGRASS:
18095 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18096 10 break;
18097
18098 case cSLASHNEXT:
18099 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18100 break;
18101
18102 case cSLASHNEXTITEM:
18103 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18104 break;
18105
18106 case cBUSHNEXT:
18107 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18108 break;
18109 }
18110 587520 }
18111 9 }
18112
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 84 times.
86 if (section_version < 16)
18113 {
18114
2/2
✓ Branch 0 taken 5483520 times.
✓ Branch 1 taken 84 times.
5483604 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18115 {
18116
2/2
✓ Branch 0 taken 5477873 times.
✓ Branch 1 taken 5647 times.
5483520 if (combobuf[tmpcounter].type == cWATER)
18117 {
18118 5647 combobuf[tmpcounter].attributes[0] = 40000L;
18119 5647 }
18120 5483520 }
18121 84 }
18122
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1 times.
86 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18123 {
18124 1 combobuf[0].walk = 0xF0;
18125 1 combobuf[0].type = 0;
18126 1 combobuf[0].flag = 0;
18127 1 }
18128 86 }
18129
18130 //Now for the new combo alias reset
18131
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
86 if(section_version<2 && keepdata)
18132 {
18133
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18134 {
18135 73728 combo_aliases[j].width = 0;
18136 73728 combo_aliases[j].height = 0;
18137 73728 combo_aliases[j].layermask = 0;
18138
18139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18140 {
18141
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].combos;
18142 73728 }
18143
18144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18145 {
18146
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].csets;
18147 73728 }
18148
18149 73728 combo_aliases[j].combos = new word[1];
18150 73728 combo_aliases[j].csets = new byte[1];
18151 73728 combo_aliases[j].combos[0] = 0;
18152 73728 combo_aliases[j].csets[0] = 0;
18153 73728 }
18154 9 }
18155
18156
18157 86 setup_combo_animations();
18158 86 setup_combo_animations2();
18159 86 return 0;
18160 86 }
18161 141746 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18162 {
18163 byte combo_has_flags;
18164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141746 times.
141746 if(!p_getc(&combo_has_flags,f,true))
18165 return qe_invalid;
18166
18167 141746 temp_combo.clear();
18168
2/2
✓ Branch 0 taken 91834 times.
✓ Branch 1 taken 49912 times.
141746 if(combo_has_flags)
18169 {
18170
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 49909 times.
49912 if(combo_has_flags&CHAS_BASIC)
18171 {
18172
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_igetl(&temp_combo.tile,f,true))
18173 {
18174 return qe_invalid;
18175 }
18176 49909 temp_combo.o_tile = temp_combo.tile;
18177
18178
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_getc(&temp_combo.flip,f,true))
18179 {
18180 return qe_invalid;
18181 }
18182
18183
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_getc(&temp_combo.walk,f,true))
18184 {
18185 return qe_invalid;
18186 }
18187
18188
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_getc(&temp_combo.type,f,true))
18189 {
18190 return qe_invalid;
18191 }
18192
18193
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_getc(&temp_combo.flag,f,true))
18194 {
18195 return qe_invalid;
18196 }
18197
18198
1/2
✓ Branch 0 taken 49909 times.
✗ Branch 1 not taken.
49909 if(!p_getc(&temp_combo.csets,f,true))
18199 {
18200 return qe_invalid;
18201 }
18202 49909 }
18203
2/2
✓ Branch 0 taken 49889 times.
✓ Branch 1 taken 23 times.
49912 if(combo_has_flags&CHAS_SCRIPT)
18204 {
18205
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 23 times.
276 for ( int32_t q = 0; q < 11; q++ )
18206 {
18207
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&temp_combo.label[q],f,true))
18208 {
18209 return qe_invalid;
18210 }
18211 253 }
18212
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18213
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18214 {
18215
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f,true))
18216 {
18217 return qe_invalid;
18218 }
18219 46 }
18220 23 }
18221
2/2
✓ Branch 0 taken 36341 times.
✓ Branch 1 taken 13571 times.
49912 if(combo_has_flags&CHAS_ANIM)
18222 {
18223
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.frames,f,true))
18224 {
18225 return qe_invalid;
18226 }
18227
18228
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.speed,f,true))
18229 {
18230 return qe_invalid;
18231 }
18232
18233
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_igetw(&temp_combo.nextcombo,f,true))
18234 {
18235 return qe_invalid;
18236 }
18237
18238
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.nextcset,f,true))
18239 {
18240 return qe_invalid;
18241 }
18242
18243
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.skipanim,f,true))
18244 {
18245 return qe_invalid;
18246 }
18247
18248
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.skipanimy,f,true))
18249 {
18250 return qe_invalid;
18251 }
18252
18253
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&temp_combo.animflags,f,true))
18254 {
18255 return qe_invalid;
18256 }
18257 13571 }
18258
2/2
✓ Branch 0 taken 45405 times.
✓ Branch 1 taken 4507 times.
49912 if(combo_has_flags&CHAS_ATTRIB)
18259 {
18260
2/2
✓ Branch 0 taken 18028 times.
✓ Branch 1 taken 4507 times.
22535 for ( int32_t q = 0; q < 4; q++ )
18261 {
18262
1/2
✓ Branch 0 taken 18028 times.
✗ Branch 1 not taken.
18028 if(!p_igetl(&temp_combo.attributes[q],f,true))
18263 {
18264 return qe_invalid;
18265 }
18266 18028 }
18267
2/2
✓ Branch 0 taken 36056 times.
✓ Branch 1 taken 4507 times.
40563 for ( int32_t q = 0; q < 8; q++ )
18268 {
18269
1/2
✓ Branch 0 taken 36056 times.
✗ Branch 1 not taken.
36056 if(!p_getc(&temp_combo.attribytes[q],f,true))
18270 {
18271 return qe_invalid;
18272 }
18273 36056 }
18274
2/2
✓ Branch 0 taken 36056 times.
✓ Branch 1 taken 4507 times.
40563 for ( int32_t q = 0; q < 8; q++ )
18275 {
18276
1/2
✓ Branch 0 taken 36056 times.
✗ Branch 1 not taken.
36056 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18277 {
18278 return qe_invalid;
18279 }
18280 36056 }
18281 4507 }
18282
2/2
✓ Branch 0 taken 48451 times.
✓ Branch 1 taken 1461 times.
49912 if(combo_has_flags&CHAS_FLAG)
18283 {
18284
1/2
✓ Branch 0 taken 1461 times.
✗ Branch 1 not taken.
1461 if(!p_igetl(&temp_combo.usrflags,f,true))
18285 {
18286 return qe_invalid;
18287 }
18288
1/2
✓ Branch 0 taken 1461 times.
✗ Branch 1 not taken.
1461 if(!p_igetw(&temp_combo.genflags,f,true))
18289 {
18290 return qe_invalid;
18291 }
18292 1461 }
18293
2/2
✓ Branch 0 taken 49525 times.
✓ Branch 1 taken 387 times.
49912 if(combo_has_flags&CHAS_TRIG)
18294 {
18295 387 int numtrigs = s_version < 36 ? 3 : 6;
18296
2/2
✓ Branch 0 taken 1725 times.
✓ Branch 1 taken 387 times.
2112 for ( int32_t q = 0; q < numtrigs; q++ )
18297 {
18298
1/2
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
1725 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18299 {
18300 return qe_invalid;
18301 }
18302 1725 }
18303
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18304 {
18305 return qe_invalid;
18306 }
18307
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.triggerbtn,f,true))
18308 {
18309 return qe_invalid;
18310 }
18311
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.triggeritem,f,true))
18312 {
18313 return qe_invalid;
18314 }
18315
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigtimer,f,true))
18316 {
18317 return qe_invalid;
18318 }
18319
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigsfx,f,true))
18320 {
18321 return qe_invalid;
18322 }
18323
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&temp_combo.trigchange,f,true))
18324 {
18325 return qe_invalid;
18326 }
18327
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.trigprox,f,true))
18328 {
18329 return qe_invalid;
18330 }
18331
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigctr,f,true))
18332 {
18333 return qe_invalid;
18334 }
18335
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18336 {
18337 return qe_invalid;
18338 }
18339
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.triglbeam,f,true))
18340 {
18341 return qe_invalid;
18342 }
18343
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigcschange,f,true))
18344 {
18345 return qe_invalid;
18346 }
18347
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.spawnitem,f,true))
18348 {
18349 return qe_invalid;
18350 }
18351
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18352 {
18353 return qe_invalid;
18354 }
18355
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.exstate,f,true))
18356 {
18357 return qe_invalid;
18358 }
18359
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetl(&temp_combo.spawnip,f,true))
18360 {
18361 return qe_invalid;
18362 }
18363
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigcopycat,f,true))
18364 {
18365 return qe_invalid;
18366 }
18367
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.trigcooldown,f,true))
18368 {
18369 return qe_invalid;
18370 }
18371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 if(s_version >= 35)
18372 {
18373
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18374 {
18375 return qe_invalid;
18376 }
18377
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_getc(&temp_combo.prompt_cs,f,true))
18378 {
18379 return qe_invalid;
18380 }
18381
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.prompt_x,f,true))
18382 {
18383 return qe_invalid;
18384 }
18385
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!p_igetw(&temp_combo.prompt_y,f,true))
18386 {
18387 return qe_invalid;
18388 }
18389 387 }
18390
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 188 times.
387 if(s_version >= 36)
18391 {
18392
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(!p_getc(&temp_combo.trig_lstate,f,true))
18393 {
18394 return qe_invalid;
18395 }
18396
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(!p_getc(&temp_combo.trig_gstate,f,true))
18397 {
18398 return qe_invalid;
18399 }
18400
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18401 {
18402 return qe_invalid;
18403 }
18404 188 }
18405
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 188 times.
387 if(s_version >= 37)
18406 {
18407
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18408 {
18409 return qe_invalid;
18410 }
18411 188 }
18412
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 114 times.
387 if(s_version >= 38)
18413 {
18414
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_combo.trig_group,f,true))
18415 {
18416 return qe_invalid;
18417 }
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18419 {
18420 return qe_invalid;
18421 }
18422 114 }
18423 387 }
18424
2/2
✓ Branch 0 taken 49829 times.
✓ Branch 1 taken 83 times.
49912 if(combo_has_flags&CHAS_LIFT)
18425 {
18426
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_combo.liftcmb,f,true))
18427 return qe_invalid;
18428
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftcs,f,true))
18429 return qe_invalid;
18430
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18431 return qe_invalid;
18432
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftundercs,f,true))
18433 return qe_invalid;
18434
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftdmg,f,true))
18435 return qe_invalid;
18436
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftlvl,f,true))
18437 return qe_invalid;
18438
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftitm,f,true))
18439 return qe_invalid;
18440
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftflags,f,true))
18441 return qe_invalid;
18442
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftgfx,f,true))
18443 return qe_invalid;
18444
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftsprite,f,true))
18445 return qe_invalid;
18446
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftsfx,f,true))
18447 return qe_invalid;
18448
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18449 return qe_invalid;
18450
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18451 return qe_invalid;
18452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(s_version >= 34)
18453 {
18454
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.lifthei,f,true))
18455 return qe_invalid;
18456
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_combo.lifttime,f,true))
18457 return qe_invalid;
18458 83 }
18459 83 }
18460
2/2
✓ Branch 0 taken 49898 times.
✓ Branch 1 taken 14 times.
49912 if(combo_has_flags&CHAS_GENERAL)
18461 {
18462
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&temp_combo.speed_mult,f,true))
18463 return qe_invalid;
18464
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&temp_combo.speed_div,f,true))
18465 return qe_invalid;
18466
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_igetzf(&temp_combo.speed_add,f,true))
18467 return qe_invalid;
18468 14 }
18469 49912 }
18470 141746 return 0;
18471 141746 }
18472 108 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18473 {
18474 108 word section_version=0;
18475 108 word section_cversion=0;
18476 108 word combos_used=0;
18477 int32_t dummy;
18478 byte padding;
18479 108 newcombo temp_combo;
18480
18481 108 reset_combo_animations();
18482 108 reset_combo_animations2();
18483 108 init_combo_classes();
18484
18485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true) //reset combos
18486 {
18487
2/2
✓ Branch 0 taken 7050240 times.
✓ Branch 1 taken 108 times.
7050348 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18488 7050240 combobuf[q].clear();
18489 108 }
18490
18491
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192) //Version info
18492 {
18493
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
18494 {
18495 return qe_invalid;
18496 }
18497 104 FFCore.quest_format[vCombos] = section_version;
18498
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_cversion,f,true))
18499 {
18500 return qe_invalid;
18501 }
18502
18503 //section size
18504
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
18505 {
18506 return qe_invalid;
18507 }
18508 104 }
18509
18510
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(section_version > 32) //Cleanup time!
18511 {
18512
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&combos_used,f,true))
18513 {
18514 return qe_invalid;
18515 }
18516
2/2
✓ Branch 0 taken 141746 times.
✓ Branch 1 taken 22 times.
141768 for(int32_t i=0; i<combos_used; i++)
18517 {
18518 141746 auto ret = readcombo_loop(f,section_version,temp_combo);
18519
1/2
✓ Branch 0 taken 141746 times.
✗ Branch 1 not taken.
141746 if(ret) return ret;
18520
2/4
✓ Branch 0 taken 141746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 141746 times.
141746 if(keepdata==true && i>=start_combo)
18521 141746 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18522 141746 }
18523 22 }
18524 else //Call the old function for all old versions
18525 {
18526 86 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(ret) return ret; //error, end read
18528 }
18529
18530
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
108 if(keepdata && false/*section_version < 34*/)
18531 {
18532 for(int32_t i=start_combo; i<combos_used; i++)
18533 {
18534 newcombo& cmb = combobuf[i];
18535 //Do anything to 'cmb' needed for version handling
18536 }
18537 }
18538
18539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
18540 {
18541
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 86 times.
108 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18542 {
18543 22 combobuf[0].walk = 0xF0;
18544 22 combobuf[0].type = 0;
18545 22 combobuf[0].flag = 0;
18546 22 }
18547 108 }
18548
18549 108 setup_combo_animations();
18550 108 setup_combo_animations2();
18551 108 return 0;
18552 108 }
18553
18554 99 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18555 {
18556 //these are here to bypass compiler warnings about unused arguments
18557 99 Header=Header;
18558 99 version=version;
18559 99 build=build;
18560
18561 int32_t dummy;
18562 99 word sversion=0, c_sversion;
18563
18564 //section version info
18565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&sversion,f,true))
18566 {
18567 return qe_invalid;
18568 }
18569
18570 99 FFCore.quest_format[vComboAliases] = sversion;
18571
18572 //al_trace("Combo aliases version %d\n", sversion);
18573
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&c_sversion,f,true))
18574 {
18575 return qe_invalid;
18576 }
18577
18578 //section size
18579
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18580 {
18581 return qe_invalid;
18582 }
18583
18584 99 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18585
18586
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 75 times.
99 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18587 {
18588 75 max_num_combo_aliases = MAX250COMBOALIASES;
18589 75 }
18590
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18591 {
18592 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18593 }
18594
18595
2/2
✓ Branch 0 taken 350208 times.
✓ Branch 1 taken 99 times.
350307 for(int32_t j=0; j<max_num_combo_aliases; j++)
18596 {
18597 byte width,height,mask,tempcset;
18598 int32_t count;
18599 word tempword;
18600 byte tempbyte;
18601
18602
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(!p_igetw(&tempword,f,true))
18603 {
18604 return qe_invalid;
18605 }
18606
18607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350208 times.
350208 if(keepdata)
18608 {
18609 350208 combo_aliases[j].combo = tempword;
18610 350208 }
18611
18612
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(!p_getc(&tempbyte,f,true))
18613 {
18614 return qe_invalid;
18615 }
18616
18617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350208 times.
350208 if(keepdata)
18618 {
18619 350208 combo_aliases[j].cset = tempbyte;
18620 350208 }
18621
18622
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(!p_getc(&width,f,true))
18623 {
18624 return qe_invalid;
18625 }
18626
18627
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(!p_getc(&height,f,true))
18628 {
18629 return qe_invalid;
18630 }
18631
18632
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(!p_getc(&mask,f,true))
18633 {
18634 return qe_invalid;
18635 }
18636
18637 350208 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18638
18639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350208 times.
350208 if(keepdata)
18640 {
18641
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(combo_aliases[j].combos != NULL)
18642 {
18643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350208 times.
350208 delete[] combo_aliases[j].combos;
18644 350208 }
18645
18646
1/2
✓ Branch 0 taken 350208 times.
✗ Branch 1 not taken.
350208 if(combo_aliases[j].csets != NULL)
18647 {
18648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350208 times.
350208 delete[] combo_aliases[j].csets;
18649 350208 }
18650
18651 350208 combo_aliases[j].width = width;
18652 350208 combo_aliases[j].height = height;
18653 350208 combo_aliases[j].layermask = mask;
18654 350208 combo_aliases[j].combos = new word[count];
18655 350208 combo_aliases[j].csets = new byte[count];
18656 350208 }
18657
18658
2/2
✓ Branch 0 taken 358693 times.
✓ Branch 1 taken 350208 times.
708901 for(int32_t k=0; k<count; k++)
18659 {
18660
1/2
✓ Branch 0 taken 358693 times.
✗ Branch 1 not taken.
358693 if(!p_igetw(&tempword,f,true))
18661 {
18662 return qe_invalid;
18663 }
18664
18665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358693 times.
358693 if(keepdata)
18666 {
18667 358693 combo_aliases[j].combos[k] = tempword;
18668 358693 }
18669 358693 }
18670
18671
2/2
✓ Branch 0 taken 358693 times.
✓ Branch 1 taken 350208 times.
708901 for(int32_t k=0; k<count; k++)
18672 {
18673
1/2
✓ Branch 0 taken 358693 times.
✗ Branch 1 not taken.
358693 if(!p_getc(&tempcset,f,true))
18674 {
18675 return qe_invalid;
18676 }
18677
18678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358693 times.
358693 if(keepdata)
18679 {
18680 358693 combo_aliases[j].csets[k] = tempcset;
18681 358693 }
18682 358693 }
18683 350208 }
18684
18685 99 word num_combo_pools = 0;
18686
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(sversion >= 4)
18687 {
18688
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&num_combo_pools,f,true))
18689 {
18690 return qe_invalid;
18691 }
18692 22 }
18693
18694
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 99 times.
811107 for(combo_pool& pool : combo_pools)
18695 {
18696 811008 pool.clear();
18697 }
18698
18699 99 combo_pool temp_cpool;
18700
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 99 times.
159 for(word cp = 0; cp < num_combo_pools; ++cp)
18701 {
18702 60 int32_t num_combos_in_pool = 0;
18703
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
60 if(!p_igetl(&num_combos_in_pool,f,true))
18704 {
18705 return qe_invalid;
18706 }
18707
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(num_combos_in_pool < 1) continue; //nothing to read
18708
18709
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 temp_cpool.clear();
18710
18711 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18712
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 60 times.
320 for(auto q = 0; q < num_combos_in_pool; ++q)
18713 {
18714
2/4
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
260 if(!p_igetl(&cp_cid,f,true))
18715 {
18716 return qe_invalid;
18717 }
18718
2/4
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
260 if(!p_getc(&cp_cs,f,true))
18719 {
18720 return qe_invalid;
18721 }
18722
2/4
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
260 if(!p_igetw(&cp_quant,f,true))
18723 {
18724 return qe_invalid;
18725 }
18726
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18727 260 }
18728
18729
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(keepdata)
18730 {
18731
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 combo_pools[cp] = temp_cpool;
18732 60 }
18733 60 }
18734
18735 99 return 0;
18736 99 }
18737
18738 108 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18739 {
18740 //these are here to bypass compiler warnings about unused arguments
18741
18742 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18743 //Capitalized cause it'll save you a headache. -Deedee
18744 108 start_cset=start_cset;
18745 108 max_csets=max_csets;
18746 108 word s_version=0;
18747
18748 miscQdata temp_misc;
18749 108 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18750
18751 byte temp_colordata[48];
18752 char temp_palname[PALNAMESIZE];
18753
18754 int32_t dummy;
18755 word palcycles;
18756
18757
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
18758 {
18759 //section version info
18760
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
18761 {
18762 return qe_invalid;
18763 }
18764
18765 104 FFCore.quest_format[vCSets] = s_version;
18766
18767 //al_trace("Color data version %d\n", s_version);
18768
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
18769 {
18770 return qe_invalid;
18771 }
18772
18773 //section size
18774
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
18775 {
18776 return qe_invalid;
18777 }
18778 104 }
18779
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
108 if (s_version < 5)
18780 {
18781
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
84 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18782
18783 //finally... section data
18784 84 int32_t q = 0;
18785 84 int32_t p = -15;
18786
2/2
✓ Branch 0 taken 20160 times.
✓ Branch 1 taken 84 times.
20244 for(int32_t i=0; i<oldpdTOTAL; ++i)
18787 {
18788 20160 memset(temp_colordata, 0, 48);
18789
18790
1/2
✓ Branch 0 taken 20160 times.
✗ Branch 1 not taken.
20160 if(!pfread(temp_colordata,48,f,true))
18791 {
18792 return qe_invalid;
18793 }
18794
18795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20160 times.
20160 if(keepdata==true)
18796 {
18797 20160 memcpy(&colordata[q*48], temp_colordata, 48);
18798 20160 }
18799 20160 ++q;
18800
8/8
✓ Branch 0 taken 18816 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 1428 times.
✓ Branch 3 taken 17388 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 1260 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 160 times.
20160 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18801 {
18802
1/2
✓ Branch 0 taken 1420 times.
✗ Branch 1 not taken.
1420 if (s_version < 5) //Bumping up the size of level palettes
18803 {
18804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1420 times.
1420 if(keepdata==true)
18805 {
18806 1420 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18807 1420 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18808 1420 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18809 1420 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18810 1420 }
18811 1420 q+=4;
18812 1420 }
18813 else
18814 {
18815 for(int m = 0; m < 4; ++m)
18816 {
18817 memset(temp_colordata, 0, 48);
18818 if(!pfread(temp_colordata,48,f,true))
18819 {
18820 return qe_invalid;
18821 }
18822 if(keepdata==true)
18823 {
18824 memcpy(&colordata[q*48], temp_colordata, 48);
18825 }
18826 ++q;
18827 }
18828 }
18829 1420 }
18830 20160 ++p;
18831 20160 }
18832
18833
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 80 times.
84 if(RealOldVerion)
18834 {
18835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18836 {
18837 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18838 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18839 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18840 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18841 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18842 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18843 4 }
18844 4 }
18845 else
18846 {
18847 80 memset(temp_colordata, 0, 48);
18848
18849
2/2
✓ Branch 0 taken 250640 times.
✓ Branch 1 taken 80 times.
250720 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18850 {
18851
1/2
✓ Branch 0 taken 250640 times.
✗ Branch 1 not taken.
250640 if(!pfread(temp_colordata,48,f,true))
18852 {
18853 return qe_invalid;
18854 }
18855
18856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250640 times.
250640 if(keepdata==true)
18857 {
18858 250640 memcpy(&colordata[q*48], temp_colordata, 48);
18859 250640 }
18860 250640 ++q;
18861
7/8
✓ Branch 0 taken 250640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19280 times.
✓ Branch 3 taken 231360 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 19120 times.
✓ Branch 6 taken 150 times.
✓ Branch 7 taken 10 times.
250640 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18862 {
18863
1/2
✓ Branch 0 taken 19270 times.
✗ Branch 1 not taken.
19270 if (s_version < 5) //Bumping up the size of level palettes
18864 {
18865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19270 times.
19270 if(keepdata==true)
18866 {
18867 19270 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18868 19270 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18869 19270 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18870 19270 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18871 19270 }
18872 19270 q+=4;
18873 19270 }
18874 else
18875 {
18876 for(int m = 0; m < 4; ++m)
18877 {
18878 memset(temp_colordata, 0, 48);
18879 if(!pfread(temp_colordata,48,f,true))
18880 {
18881 return qe_invalid;
18882 }
18883 if(keepdata==true)
18884 {
18885 memcpy(&colordata[q*48], temp_colordata, 48);
18886 }
18887 ++q;
18888 }
18889 }
18890 19270 }
18891 250640 ++p;
18892 250640 }
18893
18894
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 75 times.
80 if(s_version < 4)
18895 {
18896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18897 {
18898 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18899 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18900 5 }
18901 5 }
18902 else
18903 {
18904
2/2
✓ Branch 0 taken 249600 times.
✓ Branch 1 taken 75 times.
249675 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18905 {
18906
1/2
✓ Branch 0 taken 249600 times.
✗ Branch 1 not taken.
249600 if(!pfread(temp_colordata,48,f,true))
18907 {
18908 return qe_invalid;
18909 }
18910
18911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249600 times.
249600 if(keepdata==true)
18912 {
18913 249600 memcpy(&colordata[q*48], temp_colordata, 48);
18914 249600 }
18915 249600 ++q;
18916
5/6
✓ Branch 0 taken 249600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 230400 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 19050 times.
249600 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18917 {
18918
1/2
✓ Branch 0 taken 19050 times.
✗ Branch 1 not taken.
19050 if (s_version < 5) //Bumping up the size of level palettes
18919 {
18920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19050 times.
19050 if(keepdata==true)
18921 {
18922 19050 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18923 19050 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18924 19050 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18925 19050 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18926 19050 }
18927 19050 q+=4;
18928 19050 }
18929 else
18930 {
18931 for(int m = 0; m < 4; ++m)
18932 {
18933 memset(temp_colordata, 0, 48);
18934 if(!pfread(temp_colordata,48,f,true))
18935 {
18936 return qe_invalid;
18937 }
18938 if(keepdata==true)
18939 {
18940 memcpy(&colordata[q*48], temp_colordata, 48);
18941 }
18942 ++q;
18943 }
18944 }
18945 19050 }
18946 249600 ++p;
18947 249600 }
18948
18949 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18950 }
18951 }
18952 84 }
18953 else
18954 {
18955
2/2
✓ Branch 0 taken 209976 times.
✓ Branch 1 taken 24 times.
210000 for(int32_t i=0; i<pdTOTAL255; ++i)
18956 {
18957 209976 memset(temp_colordata, 0, 48);
18958
18959
1/2
✓ Branch 0 taken 209976 times.
✗ Branch 1 not taken.
209976 if(!pfread(temp_colordata,48,f,true))
18960 {
18961 return qe_invalid;
18962 }
18963
18964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209976 times.
209976 if(keepdata==true)
18965 {
18966 209976 memcpy(&colordata[i*48], temp_colordata, 48);
18967 209976 }
18968 209976 }
18969 }
18970
18971
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x192)||((version == 0x192)&&(build<76)))
18972 {
18973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18974 {
18975 4 init_palnames();
18976 4 }
18977 4 }
18978 else
18979 {
18980 104 int32_t palnamestoread = 0;
18981
18982
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 3)
18983 5 palnamestoread = OLDMAXLEVELS;
18984 else
18985 99 palnamestoread = 512;
18986
18987
2/2
✓ Branch 0 taken 51968 times.
✓ Branch 1 taken 104 times.
52072 for(int32_t i=0; i<palnamestoread; ++i)
18988 {
18989 51968 memset(temp_palname, 0, PALNAMESIZE);
18990
18991
1/2
✓ Branch 0 taken 51968 times.
✗ Branch 1 not taken.
51968 if(!pfread(temp_palname,PALNAMESIZE,f,true))
18992 {
18993 return qe_invalid;
18994 }
18995
18996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51968 times.
51968 if(keepdata==true)
18997 {
18998 51968 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18999 51968 }
19000 51968 }
19001
19002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
19003 {
19004
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 104 times.
1384 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19005 {
19006 1280 memset(palnames[i], 0, PALNAMESIZE);
19007 1280 }
19008 104 }
19009 }
19010
19011
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
19012 {
19013
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<256; i++)
19014 {
19015
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 26624 times.
106496 for(int32_t j=0; j<3; j++)
19016 {
19017 79872 temp_misc.cycles[i][j].first=0;
19018 79872 temp_misc.cycles[i][j].count=0;
19019 79872 temp_misc.cycles[i][j].speed=0;
19020 79872 }
19021 26624 }
19022
19023
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&palcycles,f,true))
19024 {
19025 return qe_invalid;
19026 }
19027
19028
2/2
✓ Branch 0 taken 3416 times.
✓ Branch 1 taken 104 times.
3520 for(int32_t i=0; i<palcycles; i++)
19029 {
19030
2/2
✓ Branch 0 taken 10248 times.
✓ Branch 1 taken 3416 times.
13664 for(int32_t j=0; j<3; j++)
19031 {
19032
1/2
✓ Branch 0 taken 10248 times.
✗ Branch 1 not taken.
10248 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19033 {
19034 return qe_invalid;
19035 }
19036 10248 }
19037
19038
2/2
✓ Branch 0 taken 10248 times.
✓ Branch 1 taken 3416 times.
13664 for(int32_t j=0; j<3; j++)
19039 {
19040
1/2
✓ Branch 0 taken 10248 times.
✗ Branch 1 not taken.
10248 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19041 {
19042 return qe_invalid;
19043 }
19044 10248 }
19045
19046
2/2
✓ Branch 0 taken 10248 times.
✓ Branch 1 taken 3416 times.
13664 for(int32_t j=0; j<3; j++)
19047 {
19048
1/2
✓ Branch 0 taken 10248 times.
✗ Branch 1 not taken.
10248 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19049 {
19050 return qe_invalid;
19051 }
19052 10248 }
19053 3416 }
19054
19055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
19056 {
19057 104 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19058 104 }
19059 104 }
19060
19061 108 return 0;
19062 108 }
19063
19064 108 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19065 {
19066 108 int32_t tiles_used=0;
19067 108 word section_version = 0;
19068 108 word section_cversion = 0;
19069 108 int32_t section_size= 0;
19070 108 byte *temp_tile = new byte[tilesize(tf32Bit)];
19071
19072 //Tile Expansion
19073 //if ( version >= 0x254 && build >= 41 )
19074
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
108 if (version < 0x254 && build < 41)
19075 {
19076 //al_trace("Build was < 41 when reading tiles\n");
19077 84 max_tiles = ZC250MAXTILES;
19078 84 }
19079
19080 //al_trace("Max Tiles: %d\n", max_tiles);
19081
19082
2/6
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19083 {
19084 if(keepdata==true)
19085 {
19086 if(!init_tiles(true, Header))
19087 {
19088 al_trace("Unable to initialize tiles\n");
19089 }
19090 }
19091
19092 delete[] temp_tile;
19093 temp_tile=NULL;
19094 return 0;
19095 }
19096 else
19097 {
19098
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(version > 0x192)
19099 {
19100 //section version info
19101
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
19102 {
19103 delete[] temp_tile;
19104 return qe_invalid;
19105 }
19106
19107 104 FFCore.quest_format[vTiles] = section_version;
19108
19109
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_cversion,f,true))
19110 {
19111 delete[] temp_tile;
19112 return qe_invalid;
19113 }
19114
19115 //section size
19116
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&section_size,f,true))
19117 {
19118 delete[] temp_tile;
19119 return qe_invalid;
19120 }
19121 104 }
19122
19123 //if ( build < 41 )
19124 //{
19125 // tiles_used = ZC250MAXTILES;
19126 //}
19127
19128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(version < 0x174)
19129 {
19130 tiles_used=TILES_PER_PAGE*4;
19131 } //no expanded tile space
19132
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 else if(version < 0x191)
19133 {
19134 4 tiles_used=OLDMAXTILES;
19135 4 }
19136 else
19137 {
19138 //finally... section data
19139
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
104 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19140 {
19141
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&tiles_used,f,true))
19142 {
19143 delete[] temp_tile;
19144 return qe_invalid;
19145 }
19146 24 }
19147 else
19148 {
19149
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(!p_igetw(&tiles_used,f,true))
19150 {
19151 delete[] temp_tile;
19152 return qe_invalid;
19153 }
19154 }
19155 }
19156
19157
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 tiles_used=zc_min(tiles_used, max_tiles);
19158
19159 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19160 //if ( version < 0x254 && build < 41 )
19161
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if ( version < 0x254 || (version == 0x254 && build < 41) )
19162 //if ( build < 41 )
19163 {
19164
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19165 84 }
19166 else //2.55
19167 {
19168
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19169 }
19170
19171 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19172
19173 //al_trace("tiles_used = %d\n", tiles_used);
19174
19175
2/2
✓ Branch 0 taken 2505714 times.
✓ Branch 1 taken 108 times.
2505822 for(int32_t i=0; i<tiles_used; ++i)
19176 {
19177 2505714 byte format=tf4Bit;
19178 2505714 memset(temp_tile, 0, tilesize(tf32Bit));
19179
19180
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2333476 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2505714 if((version>0x211)||((version==0x211)&&(build>4)))
19181 {
19182
1/2
✓ Branch 0 taken 2333476 times.
✗ Branch 1 not taken.
2333476 if(!p_getc(&format,f,true))
19183 {
19184 delete[] temp_tile;
19185 return qe_invalid;
19186 }
19187 2333476 }
19188
4/4
✓ Branch 0 taken 803500 times.
✓ Branch 1 taken 1702214 times.
✓ Branch 2 taken 398513 times.
✓ Branch 3 taken 404987 times.
2505714 if(section_version > 2 && !format)
19189 {
19190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404987 times.
404987 if(keepdata)
19191 {
19192 404987 reset_tile(buf,start_tile+i,tf4Bit);
19193 404987 }
19194 404987 continue;
19195 }
19196
19197
1/2
✓ Branch 0 taken 2100727 times.
✗ Branch 1 not taken.
2100727 if(!pfread(temp_tile,tilesize(format),f,true))
19198 {
19199 delete[] temp_tile;
19200 return qe_invalid;
19201 }
19202
19203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2100727 times.
2100727 if(keepdata==true)
19204 {
19205 2100727 buf[start_tile+i].format=format;
19206
19207
1/2
✓ Branch 0 taken 2100727 times.
✗ Branch 1 not taken.
2100727 if(buf[start_tile+i].data)
19208 {
19209 2100727 free(buf[start_tile+i].data);
19210 2100727 buf[start_tile+i].data=NULL;
19211 2100727 }
19212
19213 2100727 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19214 2100727 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19215 2100727 }
19216 2100727 }
19217 }
19218
19219
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19220 {
19221 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19222
2/2
✓ Branch 0 taken 12514320 times.
✓ Branch 1 taken 84 times.
12514404 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19223 {
19224
19225 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19226 12514320 reset_tile(buf,q,tf4Bit);
19227
19228
19229 /*
19230
19231 byte tempbyte;
19232 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19233 {
19234 tempbyte=buf[ZC250MAXTILES-1].data[i];
19235 buf[q].data[i] = tempbyte;
19236 }
19237 //int32_t temp = tempbyte=buf[130].data[i];
19238 //buf[q].data = buf[ZC250MAXTILES-1].data;
19239 */
19240 //reset_tile(buf,q,tf4Bit);
19241 12514320 }
19242
19243 84 }
19244
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19246 {
19247
4/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
108 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19248 {
19249
2/2
✓ Branch 0 taken 4010086 times.
✓ Branch 1 taken 84 times.
4010170 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19250 {
19251 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19252 4010086 reset_tile(buf,i,tf4Bit);
19253 4010086 }
19254 84 }
19255 else
19256 {
19257
2/2
✓ Branch 0 taken 4135880 times.
✓ Branch 1 taken 24 times.
4135904 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19258 {
19259 //al_trace("Resetting tiles for build 41+\n");
19260 4135880 reset_tile(buf,i,tf4Bit);
19261 4135880 }
19262 }
19263
19264
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19265 {
19266
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19267 {
19268 byte tempbyte;
19269 int32_t floattile=wpnsbuf[iwSwim].tile;
19270
19271 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19272 {
19273 tempbyte=buf[23].data[i];
19274 buf[23].data[i]=buf[24].data[i];
19275 buf[24].data[i]=buf[25].data[i];
19276 buf[25].data[i]=buf[26].data[i];
19277 buf[26].data[i]=tempbyte;
19278 }
19279 //swim tiles are out of order, too, but nobody cared? -Z
19280 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19281 {
19282 tempbyte=buf[floattile+11].data[i];
19283 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19284 buf[floattile+12].data[i]=tempbyte;
19285 }
19286 }
19287 4 }
19288
19289
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19290 {
19291
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19292 {
19293 byte tempbyte;
19294
19295
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19296 {
19297 512 tempbyte=buf[130].data[i];
19298 512 buf[130].data[i]=buf[132].data[i];
19299 512 buf[132].data[i]=tempbyte;
19300
19301 512 tempbyte=buf[131].data[i];
19302 512 buf[131].data[i]=buf[133].data[i];
19303 512 buf[133].data[i]=tempbyte;
19304 512 }
19305 4 }
19306 9 }
19307
19308 108 al_trace("Registering blank tiles\n");
19309 108 register_blank_tiles();
19310 108 }
19311
19312 //memset(temp_tile, 0, tilesize(tf32Bit));
19313
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 delete[] temp_tile;
19314 108 temp_tile=NULL;
19315 108 return 0;
19316 108 }
19317
19318 108 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19319 {
19320 108 byte *mf=midi_flags;
19321 int32_t dummy;
19322 word dummy2;
19323 // zcmidi_ temp_midi;
19324 int32_t tunes_to_read;
19325 108 int32_t tune_count=0;
19326 108 word section_version=0;
19327 108 zctune temp;
19328
19329
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version < 0x193)
19330 {
19331 // mf=Header->data_flags+ZQ_MIDIS2;
19332
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19333 {
19334 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19335 4 }
19336 else
19337 {
19338 tunes_to_read=MAXCUSTOMTUNES;
19339 }
19340 4 }
19341 else
19342 {
19343 //section version info
19344
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&section_version,f,true))
19345 {
19346 return qe_invalid;
19347 }
19348
19349 104 FFCore.quest_format[vMIDIs] = section_version;
19350
19351 //al_trace("Tunes version %d\n", section_version);
19352
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy2,f,true))
19353 {
19354 return qe_invalid;
19355 }
19356
19357 //section size
19358
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
19359 {
19360 return qe_invalid;
19361 }
19362
19363 //finally... section data
19364
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19365 {
19366 return qe_invalid;
19367 }
19368
19369 104 tunes_to_read=MAXCUSTOMTUNES;
19370 }
19371
19372
2/2
✓ Branch 0 taken 27216 times.
✓ Branch 1 taken 108 times.
27324 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19373 {
19374
2/2
✓ Branch 0 taken 25349 times.
✓ Branch 1 taken 1867 times.
27216 if(get_bit(mf, i))
19375 {
19376 1867 ++tune_count;
19377 1867 }
19378 27216 }
19379
19380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19381 {
19382 108 reset_tunes(tunes); //reset_midis(midis);
19383 108 }
19384
19385
2/2
✓ Branch 0 taken 26336 times.
✓ Branch 1 taken 108 times.
26444 for(int32_t i=0; i<tunes_to_read; i++)
19386 {
19387 26336 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19388
19389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26336 times.
26336 if(keepdata==true)
19390 {
19391 26336 tunes[i].reset(); // reset_midi(midis+i);
19392 26336 }
19393
19394
2/2
✓ Branch 0 taken 24469 times.
✓ Branch 1 taken 1867 times.
26336 if(get_bit(mf,i))
19395 {
19396
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1570 times.
1867 if(section_version < 4)
19397 {
19398
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19399 {
19400 return qe_invalid;
19401 }
19402 297 }
19403 else
19404 {
19405
1/2
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
1570 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19406 {
19407 return qe_invalid;
19408 }
19409 }
19410
19411
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!p_igetl(&temp.start,f,true))
19412 {
19413 return qe_invalid;
19414 }
19415
19416
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!p_igetl(&temp.loop_start,f,true))
19417 {
19418 return qe_invalid;
19419 }
19420
19421
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!p_igetl(&temp.loop_end,f,true))
19422 {
19423 return qe_invalid;
19424 }
19425
19426
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!p_igetw(&temp.loop,f,true))
19427 {
19428 return qe_invalid;
19429 }
19430
19431
1/2
✓ Branch 0 taken 1867 times.
✗ Branch 1 not taken.
1867 if(!p_igetw(&temp.volume,f,true))
19432 {
19433 return qe_invalid;
19434 }
19435
19436
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 78 times.
1867 if(Header->zelda_version < 0x193)
19437 {
19438
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19439 {
19440 return qe_invalid;
19441 }
19442 78 }
19443
19444
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1570 times.
1867 if(section_version >= 3)
19445 {
19446
1/2
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
1570 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19447 {
19448 return qe_invalid;
19449 }
19450 1570 }
19451
19452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1867 times.
1867 if(keepdata==true)
19453 {
19454 1867 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19455 1867 }
19456
19457
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1570 times.
1867 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19458 {
19459 // old format - a midi is a midi
19460
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19461 {
19462 return qe_invalid;
19463 }
19464
19465 //yes you can do this. Isn't the ? operator awesome? :)
19466
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19467 297 }
19468 else
19469 {
19470 // 'midi' could be midi or nes, gb, ... music
19471
2/4
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1570 times.
✗ Branch 3 not taken.
1570 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19472 {
19473 return qe_invalid;
19474 }
19475
19476
1/2
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
1570 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19477
19478
1/2
✓ Branch 0 taken 1570 times.
✗ Branch 1 not taken.
1570 switch(temp.format)
19479 {
19480 case MFORMAT_MIDI:
19481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1570 times.
1570 if((ptr->data=read_midi(f, true))==NULL)
19482 {
19483 return qe_invalid;
19484 }
19485
19486 1570 break;
19487
19488 default:
19489 return qe_invalid;
19490 break;
19491 }
19492 }
19493 1867 }
19494 26336 }
19495
19496 108 return 0;
19497 108 }
19498
19499 108 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19500 {
19501 int32_t dummy;
19502 ZCHEATS tempzcheats;
19503 108 char temp_use_cheats=1;
19504 108 memset(&tempzcheats, 0, sizeof(tempzcheats));
19505 108 word s_version = 0;
19506
19507
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
108 if(Header->zelda_version > 0x192)
19508 {
19509 //section version info
19510
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&s_version,f,true))
19511 {
19512 return qe_invalid;
19513 }
19514
19515 104 FFCore.quest_format[vCheats] = s_version;
19516 //al_trace("Cheats version %d\n", dummy);
19517
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetw(&dummy,f,true))
19518 {
19519 return qe_invalid;
19520 }
19521
19522 //section size
19523
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&dummy,f,true))
19524 {
19525 return qe_invalid;
19526 }
19527
19528 //finally... section data
19529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&temp_use_cheats,f,true))
19530 {
19531 return qe_invalid;
19532 }
19533 104 }
19534
19535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(Header->data_flags[ZQ_CHEATS2])
19536 {
19537
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tempzcheats.flags,f,true))
19538 {
19539 return qe_invalid;
19540 }
19541
19542
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19543 {
19544 return qe_invalid;
19545 }
19546 108 }
19547
19548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(keepdata==true)
19549 {
19550 108 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19551 108 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19552 108 }
19553
19554 108 return 0;
19555 108 }
19556
19557 268 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19558 {
19559 int32_t dummy;
19560 268 word s_version=0, s_cversion=0;
19561 byte padding;
19562 word tempw;
19563
19564 268 zinitdata temp_zinit;
19565
19566 // Legacy item properties (now integrated into itemdata)
19567 byte sword_hearts[4];
19568 byte beam_hearts[4];
19569 268 byte beam_percent=0;
19570 word beam_power[4];
19571 268 byte hookshot_length=99;
19572 268 byte hookshot_links=100;
19573 268 byte longshot_length=99;
19574 268 byte longshot_links=100;
19575 268 byte moving_fairy_hearts=3;
19576 268 byte moving_fairy_heart_percent=0;
19577 268 byte stationary_fairy_hearts=3;
19578 268 byte stationary_fairy_heart_percent=0;
19579 268 byte moving_fairy_magic=0;
19580 268 byte moving_fairy_magic_percent=0;
19581 268 byte stationary_fairy_magic=0;
19582 268 byte stationary_fairy_magic_percent=0;
19583 268 byte blue_potion_hearts=100;
19584 268 byte blue_potion_heart_percent=1;
19585 268 byte red_potion_hearts=100;
19586 268 byte red_potion_heart_percent=1;
19587 268 byte blue_potion_magic=100;
19588 268 byte blue_potion_magic_percent=1;
19589 268 byte red_potion_magic=100;
19590 268 byte red_potion_magic_percent=1;
19591
19592
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 160 times.
268 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19593
19594
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(Header->zelda_version > 0x192)
19595 {
19596 //section version info
19597
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_version,f,true))
19598 {
19599 return qe_invalid;
19600 }
19601
19602 104 FFCore.quest_format[vInitData] = s_version;
19603
19604 //al_trace("Init data version %d\n", s_version);
19605
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&s_cversion,f,true))
19606 {
19607 return qe_invalid;
19608 }
19609
19610 //section size
19611
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetl(&dummy,f,true))
19612 {
19613 return qe_invalid;
19614 }
19615 104 }
19616
19617 /* HIGHLY UNORTHODOX UPDATING THING, by L
19618 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19619 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19620 * changing from 13 to 14.
19621 */
19622
3/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 9 times.
108 if(keepdata && s_version < 14)
19623 9 fixpolsvoice=true;
19624
19625 /* End highly unorthodox updating thing */
19626
19627
5/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 26 times.
108 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19628 26 temp_zinit.jump_hero_layer_threshold=0;
19629
19630
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version >= 10)
19631 {
19632 char temp;
19633
19634 //new-style items
19635
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t j=0; j<256; j++)
19636 {
19637
2/4
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(!p_getc(&temp,f,true))
19638 return qe_invalid;
19639
19640 25344 temp_zinit.items[j] = (temp != 0);
19641 25344 }
19642 99 }
19643
19644
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 56 times.
108 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19645 {
19646 char temp;
19647
19648 //finally... section data
19649
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 56 times.
160 if((Header->zelda_version > 0x192)||
19650 //new only
19651 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19652 {
19653 //OLD-style items... sigh
19654
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 10)
19655 {
19656
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19657 {
19658 return qe_invalid;
19659 }
19660
19661 5 temp_zinit.items[iRaft]=(temp != 0);
19662
19663
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19664 {
19665 return qe_invalid;
19666 }
19667
19668 5 temp_zinit.items[iLadder]=(temp != 0);
19669
19670
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 5 temp_zinit.items[iBook]=(temp != 0);
19676
19677
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19678 {
19679 return qe_invalid;
19680 }
19681
19682 5 temp_zinit.items[iMKey]=(temp!=0);
19683
19684
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19685 {
19686 return qe_invalid;
19687 }
19688
19689 5 temp_zinit.items[iFlippers]=(temp != 0);
19690
19691
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19692 {
19693 return qe_invalid;
19694 }
19695
19696 5 temp_zinit.items[iBoots]=(temp!=0);
19697 5 }
19698 104 }
19699
19700
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 155 times.
160 if(s_version < 10)
19701 {
19702 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19703
19704
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19705 {
19706 return qe_invalid;
19707 }
19708
19709
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19710 {
19711 return qe_invalid;
19712 }
19713
19714
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19715 {
19716 return qe_invalid;
19717 }
19718
19719
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19720 {
19721 return qe_invalid;
19722 }
19723
19724
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19725 {
19726 return qe_invalid;
19727 }
19728
19729
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19730 {
19731 return qe_invalid;
19732 }
19733
19734
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19735 {
19736 return qe_invalid;
19737 }
19738
19739 //old only
19740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19741 {
19742 tempring=(tempring)?(1<<(tempring-1)):0;
19743 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19744 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19745 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19746 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19747 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19748 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19749 }
19750
19751 //rings start at level 2... wtf
19752 //account for this -DD
19753 5 tempring <<= 1;
19754
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19755
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19756
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19757
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19758 //bracelet ALSO starts at level 2 :-( -DD
19759 5 tempbracelet<<=1;
19760
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19761
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19762
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19763
19764 //new only
19765
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19766 {
19767 for(int32_t q=0; q<32; q++)
19768 {
19769 if(!p_getc(&padding,f,true))
19770 {
19771 return qe_invalid;
19772 }
19773 }
19774 }
19775
19776 char tempcandle, tempboomerang, temparrow, tempwhistle;
19777
19778
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19779 {
19780 return qe_invalid;
19781 }
19782
19783
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19784 {
19785 return qe_invalid;
19786 }
19787
19788
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19789 {
19790 return qe_invalid;
19791 }
19792
19793
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19794 {
19795 return qe_invalid;
19796 }
19797
19798
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19799
19800
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19801 {
19802 return qe_invalid;
19803 }
19804
19805 //old only
19806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19807 {
19808 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19809 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19810 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19811 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19812 }
19813
19814
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19815
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19816
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19817
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19818 //What about the potion...?
19819
19820 5 }
19821
19822
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 80 times.
160 if(s_version < 29)
19823 {
19824 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19825 //to jab out my eye...
19826
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
19827 return qe_invalid;
19828 80 temp_zinit.bombs = padding;
19829
19830
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
19831 return qe_invalid;
19832 80 temp_zinit.super_bombs = padding;
19833 80 }
19834
19835 //Back to more OLD item code
19836
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
160 if(s_version < 10)
19837 {
19838
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19839 //new only
19840 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19841 {
19842
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19843 {
19844 return qe_invalid;
19845 }
19846
19847
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19848
19849
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19850 {
19851 return qe_invalid;
19852 }
19853
19854
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19855
19856
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19857 {
19858 return qe_invalid;
19859 }
19860
19861
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19862
19863
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19864 {
19865 return qe_invalid;
19866 }
19867
19868
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19869
19870
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19871 {
19872 return qe_invalid;
19873 }
19874
19875
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19876
19877
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19878 {
19879 return qe_invalid;
19880 }
19881
19882
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19883
19884
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19885 {
19886 return qe_invalid;
19887 }
19888
19889
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19890
19891
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19892 {
19893 return qe_invalid;
19894 }
19895
19896
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19897
19898
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19899 {
19900 return qe_invalid;
19901 }
19902
19903
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19904
19905
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19906 {
19907 return qe_invalid;
19908 }
19909
19910
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19911 {
19912 for(int32_t q=0; q<32; q++)
19913 {
19914 if(!p_getc(&padding,f,true))
19915 {
19916 return qe_invalid;
19917 }
19918 }
19919 }
19920 5 }
19921 5 }
19922
19923 //old only
19924
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19925 {
19926 byte equipment, items; //bit flags
19927
19928 if(!p_getc(&equipment,f,true))
19929 {
19930 return qe_invalid;
19931 }
19932
19933 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19934 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19935 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19936 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19937 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19938 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19939
19940
19941 if(!p_getc(&items,f,true))
19942 {
19943 return qe_invalid;
19944 }
19945
19946 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19947 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19948 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19949 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19950 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19951 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19952 }
19953
19954 if(!p_getc(&temp_zinit.hc,f,true))
19955 {
19956 return qe_invalid;
19957 }
19958
19959
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 14)
19960 {
19961 byte temphp;
19962
19963
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
19964 {
19965 return qe_invalid;
19966 }
19967
19968 5 temp_zinit.start_heart=temphp;
19969
19970
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
19971 {
19972 return qe_invalid;
19973 }
19974
19975 5 temp_zinit.cont_heart=temphp;
19976 5 }
19977 else
19978 {
19979
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.start_heart,f,true))
19980 {
19981 return qe_invalid;
19982 }
19983
19984
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.cont_heart,f,true))
19985 {
19986 return qe_invalid;
19987 }
19988 }
19989
19990
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.hcp,f,true))
19991 {
19992 return qe_invalid;
19993 }
19994
19995
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version >= 14)
19996 {
19997
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
19998 {
19999 return qe_invalid;
20000 }
20001
20002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version<16) // July 2007
20003 {
20004 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20005 temp_zinit.hcp_per_hc = 0xFF;
20006
20007 //Dispose of legacy rule
20008 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20009 }
20010 99 }
20011
20012
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 24 times.
104 if(s_version < 29)
20013 {
20014
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
20015 return qe_invalid;
20016 80 temp_zinit.max_bombs = padding;
20017 80 }
20018
20019
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.keys,f,true))
20020 {
20021 return qe_invalid;
20022 }
20023
20024
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_igetw(&temp_zinit.rupies,f,true))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.triforce,f,true))
20030 {
20031 return qe_invalid;
20032 }
20033
20034
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20035 {
20036
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20037 {
20038
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.map[i],f,true))
20039 {
20040 return qe_invalid;
20041 }
20042 6336 }
20043
20044
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20045 {
20046
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.compass[i],f,true))
20047 {
20048 return qe_invalid;
20049 }
20050 6336 }
20051 99 }
20052 else
20053 {
20054
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20055 {
20056
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20057 {
20058 return qe_invalid;
20059 }
20060 160 }
20061
20062
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20063 {
20064
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20065 {
20066 return qe_invalid;
20067 }
20068 160 }
20069 }
20070
20071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version > 0x192)||
20072 //new only
20073 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20074 {
20075
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20076 {
20077
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 99 times.
6435 for(int32_t i=0; i<64; i++)
20078 {
20079
2/4
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6336 times.
6336 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20080 {
20081 return qe_invalid;
20082 }
20083 6336 }
20084 99 }
20085 else
20086 {
20087
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20088 {
20089
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20090 {
20091 return qe_invalid;
20092 }
20093 160 }
20094 }
20095 104 }
20096
20097
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1664 times.
1768 for(int32_t i=0; i<16; i++)
20098 {
20099
2/4
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1664 times.
1664 if(!p_getc(&temp_zinit.misc[i],f,true))
20100 {
20101 return qe_invalid;
20102 }
20103 1664 }
20104
20105
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
124 if(s_version < 15) for(int32_t i=0; i<4; i++)
20106 {
20107
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20108 {
20109 return qe_invalid;
20110 }
20111 25 }
20112
20113
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.last_map,f,true))
20114 {
20115 return qe_invalid;
20116 }
20117
20118
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.last_screen,f,true))
20119 {
20120 return qe_invalid;
20121 }
20122
20123
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version < 14)
20124 {
20125 byte tempmp;
20126
20127
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20128 {
20129 return qe_invalid;
20130 }
20131
20132 5 temp_zinit.max_magic=tempmp;
20133
20134
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20135 {
20136 return qe_invalid;
20137 }
20138
20139 5 temp_zinit.magic=tempmp;
20140 5 }
20141 else
20142 {
20143
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_magic,f,true))
20144 {
20145 return qe_invalid;
20146 }
20147
20148
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.magic,f,true))
20149 {
20150 return qe_invalid;
20151 }
20152 }
20153
20154
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version < 15)
20155 {
20156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20157 {
20158 5 temp_zinit.max_magic*=32;
20159 5 temp_zinit.magic*=32;
20160 5 }
20161
20162
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20163 {
20164
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20165 {
20166 return qe_invalid;
20167 }
20168 20 }
20169
20170
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174 5 }
20175 else
20176 {
20177
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20178 {
20179 return qe_invalid;
20180 }
20181 }
20182
20183
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version < 15)
20184 {
20185 byte tempbp;
20186
20187
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20188 {
20189
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20190 {
20191 return qe_invalid;
20192 }
20193
20194 20 beam_power[i]=tempbp;
20195 20 }
20196
20197
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20198 {
20199 return qe_invalid;
20200 }
20201
20202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20203 {
20204 if(!p_getc(&hookshot_length,f,true))
20205 {
20206 return qe_invalid;
20207 }
20208
20209 if(!p_getc(&longshot_links,f,true))
20210 {
20211 return qe_invalid;
20212 }
20213
20214 if(!p_getc(&longshot_length,f,true))
20215 {
20216 return qe_invalid;
20217 }
20218 }
20219 5 }
20220
20221
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20222 {
20223 return qe_invalid;
20224 }
20225
20226
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20227 {
20228 return qe_invalid;
20229 }
20230
20231
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.subscreen,f,true))
20232 {
20233 return qe_invalid;
20234 }
20235
20236 //old only
20237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version == 0x192)&&(Header->build<174))
20238 {
20239 for(int32_t i=0; i<32; i++)
20240 {
20241 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20242 {
20243 return qe_invalid;
20244 }
20245 }
20246 }
20247
20248
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20249 {
20250
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version <= 10)
20251 {
20252 byte tempbyte;
20253
20254
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20255 {
20256 return qe_invalid;
20257 }
20258
20259 5 temp_zinit.start_dmap = (word)tempbyte;
20260 5 }
20261 else
20262 {
20263
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20264 {
20265 return qe_invalid;
20266 }
20267 }
20268
20269
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20270 {
20271 return qe_invalid;
20272 }
20273 104 }
20274
20275
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 24 times.
104 if(s_version>1 && s_version < 29)
20276 {
20277
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_getc(&padding,f,true))
20278 return qe_invalid;
20279 75 temp_zinit.arrows = padding;
20280
20281
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_getc(&padding,f,true))
20282 return qe_invalid;
20283 75 temp_zinit.max_arrows = padding;
20284 75 }
20285
20286
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 99 times.
104 if(s_version>2)
20287 {
20288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(s_version <= 10)
20289 {
20290 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20291 {
20292 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20293 {
20294 return qe_invalid;
20295 }
20296 }
20297 }
20298 else
20299 {
20300
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXLEVELS; i++)
20301 {
20302
2/4
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50688 times.
✗ Branch 3 not taken.
50688 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20303 {
20304 return qe_invalid;
20305 }
20306 50688 }
20307 }
20308 99 }
20309
20310
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>3)
20311 {
20312
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20313 {
20314 return qe_invalid;
20315 }
20316
20317
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20318 {
20319 return qe_invalid;
20320 }
20321
20322
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20323 {
20324 return qe_invalid;
20325 }
20326
20327
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20328 {
20329 return qe_invalid;
20330 }
20331
20332
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20333 {
20334 return qe_invalid;
20335 }
20336
20337
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20338 {
20339 return qe_invalid;
20340 }
20341
20342
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20343 {
20344 return qe_invalid;
20345 }
20346
20347
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20348 {
20349 return qe_invalid;
20350 }
20351
20352
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20353
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20354 99 }
20355
20356
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>4 && s_version<15)
20357 {
20358 if(!p_getc(&moving_fairy_hearts,f,true))
20359 {
20360 return qe_invalid;
20361 }
20362
20363 if(!p_getc(&moving_fairy_heart_percent,f,true))
20364 {
20365 return qe_invalid;
20366 }
20367 }
20368
20369
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>5 && s_version < 10)
20370 {
20371 if(!p_getc(&temp,f,true))
20372 {
20373 return qe_invalid;
20374 }
20375
20376 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20377 }
20378
20379
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
104 if(s_version>6 && s_version<15)
20380 {
20381 if(!p_getc(&stationary_fairy_hearts,f,true))
20382 {
20383 return qe_invalid;
20384 }
20385
20386 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20387 {
20388 return qe_invalid;
20389 }
20390
20391 if(!p_getc(&moving_fairy_magic,f,true))
20392 {
20393 return qe_invalid;
20394 }
20395
20396 if(!p_getc(&moving_fairy_magic_percent,f,true))
20397 {
20398 return qe_invalid;
20399 }
20400
20401 if(!p_getc(&stationary_fairy_magic,f,true))
20402 {
20403 return qe_invalid;
20404 }
20405
20406 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20407 {
20408 return qe_invalid;
20409 }
20410
20411 if(!p_getc(&blue_potion_hearts,f,true))
20412 {
20413 return qe_invalid;
20414 }
20415
20416 if(!p_getc(&blue_potion_heart_percent,f,true))
20417 {
20418 return qe_invalid;
20419 }
20420
20421 if(!p_getc(&red_potion_hearts,f,true))
20422 {
20423 return qe_invalid;
20424 }
20425
20426 if(!p_getc(&red_potion_heart_percent,f,true))
20427 {
20428 return qe_invalid;
20429 }
20430
20431 if(!p_getc(&blue_potion_magic,f,true))
20432 {
20433 return qe_invalid;
20434 }
20435
20436 if(!p_getc(&blue_potion_magic_percent,f,true))
20437 {
20438 return qe_invalid;
20439 }
20440
20441 if(!p_getc(&red_potion_magic,f,true))
20442 {
20443 return qe_invalid;
20444 }
20445
20446 if(!p_getc(&red_potion_magic_percent,f,true))
20447 {
20448 return qe_invalid;
20449 }
20450 }
20451
20452
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>6)
20453 {
20454
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20455 {
20456 return qe_invalid;
20457 }
20458 99 }
20459
20460
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>7)
20461 {
20462
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20463 {
20464 return qe_invalid;
20465 }
20466 99 }
20467
20468
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>8)
20469 {
20470
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20471 {
20472 return qe_invalid;
20473 }
20474
20475
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.max_keys,f,true))
20476 {
20477 return qe_invalid;
20478 }
20479 99 }
20480
20481
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>16)
20482 {
20483
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.gravity,f,true))
20484 {
20485 return qe_invalid;
20486 }
20487
20488
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.terminalv,f,true))
20489 {
20490 return qe_invalid;
20491 }
20492
20493
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_speed,f,true))
20494 {
20495 return qe_invalid;
20496 }
20497
20498
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.transition_type,f,true))
20499 {
20500 return qe_invalid;
20501 }
20502
20503
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20504 {
20505 return qe_invalid;
20506 }
20507 99 }
20508
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20509 5 temp_zinit.msg_speed = 0;
20510
20511
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(s_version>17)
20512 {
20513
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20514 {
20515 return qe_invalid;
20516 }
20517 99 }
20518
20519 //expaned init data for larger values in 2.55
20520
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20521 {
20522
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.bombs,f,true))
20523 {
20524 return qe_invalid;
20525 }
20526
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20527 {
20528 return qe_invalid;
20529 }
20530
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20531 {
20532 return qe_invalid;
20533 }
20534
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20535 {
20536 return qe_invalid;
20537 }
20538
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.arrows,f,true))
20539 {
20540 return qe_invalid;
20541 }
20542
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20543 {
20544 return qe_invalid;
20545 }
20546
20547 24 }
20548
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if ( s_version >= 20 )
20549 {
20550
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.heroStep,f,true))
20551 {
20552 return qe_invalid;
20553 }
20554 24 }
20555 else
20556 {
20557 80 temp_zinit.heroStep = 150; //1.5 pixels per frame
20558 }
20559
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 80 times.
104 if ( s_version >= 21 )
20560 {
20561
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20562 {
20563 return qe_invalid;
20564 }
20565 24 }
20566 else
20567 {
20568 80 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20569 }
20570 //old only
20571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version == 0x192)&&(Header->build<174))
20572 {
20573 byte items2;
20574
20575 if(!p_getc(&items2,f,true))
20576 {
20577 return qe_invalid;
20578 }
20579
20580 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20581 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20582 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20583 }
20584
20585
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x193)
20586 {
20587 for(int32_t q=0; q<96; q++)
20588 {
20589 if(!p_getc(&padding,f,true))
20590 {
20591 return qe_invalid;
20592 }
20593 }
20594
20595 //new only
20596 if((Header->zelda_version == 0x192)&&(Header->build>173))
20597 {
20598 if(!p_getc(&padding,f,true))
20599 {
20600 return qe_invalid;
20601 }
20602
20603 if(!p_getc(&padding,f,true))
20604 {
20605 return qe_invalid;
20606 }
20607 }
20608 }
20609 104 }
20610
20611
3/6
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
164 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20612 {
20613 //temp_zinit.shield=i_smallshield;
20614
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 56 times.
65 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20615
20616
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20617 9 temp_zinit.items[sshieldid] = true;
20618 9 }
20619
20620
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20621 {
20622 4 temp_zinit.hc=3;
20623 4 temp_zinit.start_heart=3;
20624 4 temp_zinit.cont_heart=3;
20625 4 temp_zinit.max_bombs=8;
20626 4 }
20627
20628
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20629 {
20630 4 sword_hearts[0]=0;
20631 4 sword_hearts[1]=5;
20632 4 sword_hearts[2]=12;
20633 4 sword_hearts[3]=21;
20634 4 }
20635
20636
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20637 {
20638 4 temp_zinit.last_map=0;
20639 4 temp_zinit.last_screen=0;
20640 4 }
20641
20642
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20643 {
20644 4 temp_zinit.max_magic=0;
20645 4 temp_zinit.magic=0;
20646
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20647 4 }
20648
20649
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20650 {
20651
20652
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20653 {
20654 16 beam_hearts[x]=100;
20655 16 }
20656
20657
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20658 {
20659
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20660
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20661 16 }
20662
20663
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20664 {
20665
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20666 16 }
20667
20668
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20669 4 hookshot_links=100;
20670 4 temp_zinit.msg_more_x=224;
20671 4 temp_zinit.msg_more_y=64;
20672 4 }
20673
20674 // Okay, let's put these legacy values into itemsbuf.
20675
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(s_version < 15)
20676
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20677 {
20678
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20679 {
20680 case iFairyStill:
20681 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20682 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20683 9 itemsbuf[i].misc3 = 0;
20684 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20685 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20686 9 break;
20687
20688 case iFairyMoving:
20689 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20690 9 itemsbuf[i].misc2 = moving_fairy_magic;
20691 9 itemsbuf[i].misc3 = 50;
20692 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20693 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20694 9 break;
20695
20696 case iRPotion:
20697 9 itemsbuf[i].misc1 = red_potion_hearts;
20698 9 itemsbuf[i].misc2 = red_potion_magic;
20699 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20700 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20701 9 break;
20702
20703 case iBPotion:
20704 9 itemsbuf[i].misc1 = blue_potion_hearts;
20705 9 itemsbuf[i].misc2 = blue_potion_magic;
20706 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20707 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20708 9 break;
20709
20710 case iSword:
20711 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20712 9 itemsbuf[i].misc1 = beam_hearts[0];
20713 9 itemsbuf[i].misc2 = beam_power[0];
20714 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20715
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20716 9 break;
20717
20718 case iWSword:
20719 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20720 9 itemsbuf[i].misc1 = beam_hearts[1];
20721 9 itemsbuf[i].misc2 = beam_power[1];
20722
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20723 9 break;
20724
20725 case iMSword:
20726 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20727 9 itemsbuf[i].misc1 = beam_hearts[2];
20728 9 itemsbuf[i].misc2 = beam_power[2];
20729
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20730 9 break;
20731
20732 case iXSword:
20733 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20734 9 itemsbuf[i].misc1 = beam_hearts[3];
20735 9 itemsbuf[i].misc2 = beam_power[3];
20736
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20737 9 break;
20738
20739 case iHookshot:
20740 9 itemsbuf[i].misc1 = hookshot_length;
20741 9 itemsbuf[i].misc2 = hookshot_links;
20742 9 break;
20743
20744 case iLongshot:
20745 9 itemsbuf[i].misc1 = longshot_length;
20746 9 itemsbuf[i].misc2 = longshot_links;
20747 9 break;
20748 }
20749 2313 }
20750
20751
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20752 {
20753 //was new subscreen rule
20754
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20755
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20756 4 }
20757
20758
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20759 {
20760 4 temp_zinit.start_dmap=0;
20761 4 }
20762
20763
3/6
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20764 {
20765
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20766 4 }
20767
20768
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
108 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20769 {
20770 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20771 temp_zinit.max_rupees=999;
20772 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20773 }
20774
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20775 {
20776 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20777 temp_zinit.max_bombs = 8;
20778 }
20779 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20780 //time to ensure that we port all new values properly:
20781
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
108 if(Header->zelda_version < 0x250)
20782 {
20783
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20784 9 }
20785
20786
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 21)
20787 {
20788
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20789 {
20790 return qe_invalid;
20791 }
20792
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20793 {
20794 return qe_invalid;
20795 }
20796
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20797 {
20798 return qe_invalid;
20799 }
20800
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20801 {
20802 return qe_invalid;
20803 }
20804 24 }
20805 else
20806 {
20807 84 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20808 84 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20809 84 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20810 84 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20811 }
20812
20813
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 22)
20814 {
20815
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 24 times.
624 for(int32_t q = 0; q < 25; ++q)
20816 {
20817
2/4
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 600 times.
600 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20818 {
20819 return qe_invalid;
20820 }
20821 600 }
20822
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 24 times.
624 for(int32_t q = 0; q < 25; ++q)
20823 {
20824
2/4
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 600 times.
600 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20825 {
20826 return qe_invalid;
20827 }
20828 600 }
20829 24 }
20830 else
20831 {
20832
2/2
✓ Branch 0 taken 2100 times.
✓ Branch 1 taken 84 times.
2184 for(int32_t q = 0; q < 25; ++q)
20833 {
20834 2100 temp_zinit.scrcnt[q] = 0;
20835 2100 temp_zinit.scrmaxcnt[q] = 0;
20836 2100 }
20837 }
20838
20839
20840
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 23)
20841 {
20842
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.dither_type,f,true))
20843 {
20844 return qe_invalid;
20845 }
20846
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.dither_arg,f,true))
20847 {
20848 return qe_invalid;
20849 }
20850
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.dither_percent,f,true))
20851 {
20852 return qe_invalid;
20853 }
20854
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20855 {
20856 return qe_invalid;
20857 }
20858
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20859 {
20860 return qe_invalid;
20861 }
20862 24 }
20863 else
20864 {
20865 84 temp_zinit.dither_type = 0;
20866 84 temp_zinit.dither_arg = 0;
20867 84 temp_zinit.dither_percent = 20;
20868 84 temp_zinit.def_lightrad = 24;
20869 84 temp_zinit.transdark_percent = 0;
20870 }
20871
20872
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 24)
20873 {
20874
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.darkcol,f,true))
20875 {
20876 return qe_invalid;
20877 }
20878 24 }
20879 else
20880 {
20881 84 temp_zinit.darkcol = BLACK;
20882 }
20883
20884
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 25)
20885 {
20886
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetl(&temp_zinit.gravity2,f,true))
20887 {
20888 return qe_invalid;
20889 }
20890
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20891 {
20892 return qe_invalid;
20893 }
20894 24 }
20895 else
20896 {
20897 84 temp_zinit.gravity2 = temp_zinit.gravity*100;
20898 84 temp_zinit.swimgravity = 5;
20899 }
20900
20901
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 26)
20902 {
20903
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20904 {
20905 return qe_invalid;
20906 }
20907
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20908 {
20909 return qe_invalid;
20910 }
20911
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20912 {
20913 return qe_invalid;
20914 }
20915 24 }
20916 else
20917 {
20918 84 temp_zinit.heroSideswimUpStep = 150;
20919 84 temp_zinit.heroSideswimSideStep = 100;
20920 84 temp_zinit.heroSideswimDownStep = 75;
20921 }
20922
20923
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 27)
20924 {
20925
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20926 {
20927 return qe_invalid;
20928 }
20929 24 }
20930 else
20931 {
20932 84 temp_zinit.exitWaterJump = 0;
20933 }
20934
20935
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 29)
20936 {
20937
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20938 {
20939 return qe_invalid;
20940 }
20941 24 }
20942 else
20943 {
20944 84 temp_zinit.bunny_ltm = 0;
20945 }
20946
20947
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 30)
20948 {
20949
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20950 {
20951 return qe_invalid;
20952 }
20953 24 }
20954 else
20955 {
20956 84 temp_zinit.switchhookstyle = 1;
20957 }
20958
20959
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 84 times.
108 if(s_version > 31)
20960 {
20961
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20962 {
20963 return qe_invalid;
20964 }
20965 24 }
20966 else
20967 {
20968
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20969
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20970 }
20971
20972
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 temp_zinit.clear_genscript();
20973
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 88 times.
108 if(s_version > 32)
20974 {
20975 20 word numgenscript = 0;
20976
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_igetw(&numgenscript,f,true))
20977 return qe_invalid;
20978
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
21 for(auto q = 1; q < numgenscript; ++q)
20979 {
20980
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
20981 return qe_invalid;
20982
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
20983 continue;
20984 1 temp_zinit.gen_doscript[q] = padding&1;
20985
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
20986 return qe_invalid;
20987
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
20988 return qe_invalid;
20989
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
20990
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
20991 return qe_invalid;
20992
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
20993 return qe_invalid;
20994
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
20995 return qe_invalid;
20996
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
20997 return qe_invalid;
20998 1 }
20999 20 }
21000
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 99 times.
108 if(s_version > 33)
21001 {
21002
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21003 return qe_invalid;
21004
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21005 return qe_invalid;
21006 9 }
21007
21008
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(keepdata==true)
21009 {
21010
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 zinit = temp_zinit;
21011
21012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(zinit.heroAnimationStyle==las_zelda3slow)
21013 {
21014 hero_animation_speed=2;
21015 }
21016 else
21017 {
21018 108 hero_animation_speed=1;
21019 }
21020 108 }
21021
21022 108 return 0;
21023 428 }
21024
21025 /*
21026 void setupitemdropsets()
21027 {
21028 for(int32_t i=0; i<isMAX; i++)
21029 {
21030 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21031 }
21032 }
21033 */
21034
21035 103 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21036 {
21037 103 build=build; // here to prevent compiler warnings
21038 dword dummy_dword;
21039 103 word item_drop_sets_to_read=0;
21040 item_drop_object tempitemdrop;
21041 103 word s_version=0, s_cversion=0;
21042
21043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(keepdata)
21044 {
21045
2/2
✓ Branch 0 taken 26368 times.
✓ Branch 1 taken 103 times.
26471 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21046 {
21047 26368 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21048 26368 }
21049 103 }
21050
21051
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 4 times.
103 if(version > 0x192)
21052 {
21053 99 item_drop_sets_to_read=0;
21054
21055 //section version info
21056
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
21057 {
21058 return qe_invalid;
21059 }
21060
21061 99 FFCore.quest_format[vItemDropsets] = s_version;
21062
21063 //al_trace("Item drop sets version %d\n", s_version);
21064
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
21065 {
21066 return qe_invalid;
21067 }
21068
21069 //section size
21070
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_dword,f,true))
21071 {
21072 return qe_invalid;
21073 }
21074
21075 //finally... section data
21076
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&item_drop_sets_to_read,f,true))
21077 {
21078 return qe_invalid;
21079 }
21080 99 }
21081 else
21082 {
21083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21084 {
21085 4 init_item_drop_sets();
21086 4 }
21087 }
21088
21089
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 99 times.
103 if(s_version>=1)
21090 {
21091
2/2
✓ Branch 0 taken 1886 times.
✓ Branch 1 taken 99 times.
1985 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21092 {
21093
1/2
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
1886 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21094 {
21095 return qe_invalid;
21096 }
21097
21098
2/2
✓ Branch 0 taken 18860 times.
✓ Branch 1 taken 1886 times.
20746 for(int32_t j=0; j<10; ++j)
21099 {
21100
1/2
✓ Branch 0 taken 18860 times.
✗ Branch 1 not taken.
18860 if(!p_igetw(&tempitemdrop.item[j],f,true))
21101 {
21102 return qe_invalid;
21103 }
21104 18860 }
21105
21106
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 1886 times.
22632 for(int32_t j=0; j<11; ++j)
21107 {
21108
1/2
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
20746 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21109 {
21110 return qe_invalid;
21111 }
21112 20746 }
21113
21114 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21115 // overrides the quest's set #12.
21116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1886 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1886 if(s_version<2 && i==12)
21117 continue;
21118
21119 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21120
1/4
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1886 if(s_version<2) for(int32_t j=0; j<10; ++j)
21121 {
21122 int32_t it = tempitemdrop.item[j];
21123
21124 if((itemsbuf[it].family == itype_rupee
21125 && ((itemsbuf[it].amount)&0xFFF) == 10)
21126 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21127 {
21128 tempitemdrop.chance[j+1]=0;
21129 }
21130 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21131 {
21132 tempitemdrop.chance[j+1]=0;
21133 }
21134
21135 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21136 if(itemsbuf[it].family == itype_misc)
21137 {
21138 // If a non-gameplay item was selected, then item drop was aborted.
21139 // Reflect this by increasing the 'Nothing' chance accordingly.
21140 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21141 tempitemdrop.chance[j+1]=0;
21142 }
21143 }
21144
21145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1886 times.
1886 if(keepdata)
21146 {
21147 1886 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21148 1886 }
21149 1886 }
21150 99 }
21151
21152 103 return 0;
21153 103 }
21154
21155 99 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21156 {
21157 int32_t temp_num;
21158 dword dummy_dword;
21159 word num_favorite_combos;
21160 word num_favorite_combo_aliases;
21161 99 word s_version=0, s_cversion=0;
21162
21163 //section version info
21164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&s_version,f,true))
21165 {
21166 return qe_invalid;
21167 }
21168
21169 99 FFCore.quest_format[vFavourites] = s_version;
21170
21171
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
21172 {
21173 return qe_invalid;
21174 }
21175
21176 //section size
21177
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_dword,f,true))
21178 {
21179 return qe_invalid;
21180 }
21181
21182 99 word per_row = FAVORITECOMBO_PER_ROW;
21183
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
99 if(s_version >= 3)
21184
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&per_row,f,true))
21185 return qe_invalid;
21186 //finally... section data
21187
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&num_favorite_combos,f,true))
21188 {
21189 return qe_invalid;
21190 }
21191
21192 //Hack; port old favorite combos
21193
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
99 if(s_version < 3 && num_favorite_combos == 100)
21194 90 per_row = 13;
21195
21196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
21197 {
21198
2/2
✓ Branch 0 taken 29700 times.
✓ Branch 1 taken 99 times.
29799 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21199 29700 favorite_combos[q] = -1;
21200
2/2
✓ Branch 0 taken 29700 times.
✓ Branch 1 taken 99 times.
29799 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21201 29700 favorite_comboaliases[q] = -1;
21202 99 }
21203
2/2
✓ Branch 0 taken 9449 times.
✓ Branch 1 taken 99 times.
9548 for(int32_t i=0; i<num_favorite_combos; i++)
21204 {
21205
1/2
✓ Branch 0 taken 9449 times.
✗ Branch 1 not taken.
9449 if(!p_igetl(&temp_num,f,true))
21206 {
21207 return qe_invalid;
21208 }
21209
21210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9449 times.
9449 if(keepdata)
21211 {
21212
2/2
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 9000 times.
9449 if(per_row == FAVORITECOMBO_PER_ROW)
21213 449 favorite_combos[i]=temp_num;
21214 else
21215 {
21216 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21217 9000 favorite_combos[new_i]=temp_num;
21218 }
21219 9449 }
21220 9449 }
21221
21222
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21223 {
21224 return qe_invalid;
21225 }
21226
21227
2/2
✓ Branch 0 taken 9000 times.
✓ Branch 1 taken 99 times.
9099 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21228 {
21229
1/2
✓ Branch 0 taken 9000 times.
✗ Branch 1 not taken.
9000 if(!p_igetl(&temp_num,f,true))
21230 {
21231 return qe_invalid;
21232 }
21233
21234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(keepdata)
21235 {
21236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(per_row == FAVORITECOMBO_PER_ROW)
21237 favorite_comboaliases[i]=temp_num;
21238 else
21239 {
21240 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21241 9000 favorite_comboaliases[new_i]=temp_num;
21242 }
21243 9000 }
21244 9000 }
21245
21246 99 word max_combo_cols = 0;
21247 99 word max_mappages = 0;
21248
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 9 times.
99 if(s_version >= 2)
21249 {
21250
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&max_combo_cols,f,true))
21251 return qe_invalid;
21252 9 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21253
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int q = 0; q < max_combo_cols; ++q)
21254 {
21255
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp,f,true))
21256 return qe_invalid;
21257
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp2,f,true))
21258 return qe_invalid;
21259
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tmp3,f,true))
21260 return qe_invalid;
21261
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
36 if(keepdata && q < MAX_COMBO_COLS)
21262 {
21263 36 First[q] = tmp;
21264 36 combo_alistpos[q] = tmp2;
21265 36 combo_pool_listpos[q] = tmp3;
21266 36 }
21267 36 }
21268
21269
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&max_mappages,f,true))
21270 return qe_invalid;
21271
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 9 times.
90 for(int q = 0; q < max_mappages; ++q)
21272 {
21273
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetl(&tmp,f,true))
21274 return qe_invalid;
21275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_igetl(&tmp2,f,true))
21276 return qe_invalid;
21277
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && q < MAX_MAPPAGE_BTNS)
21278 {
21279 81 map_page[q].map = tmp;
21280 81 map_page[q].screen = tmp2;
21281 81 }
21282 81 }
21283 9 }
21284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
21285 {
21286
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 99 times.
459 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21287 {
21288 360 First[q] = 0;
21289 360 combo_alistpos[q] = 0;
21290 360 combo_pool_listpos[q] = 0;
21291 360 }
21292
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 99 times.
909 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21293 {
21294 810 map_page[q].map = 0;
21295 810 map_page[q].screen = 0;
21296 810 }
21297 99 }
21298
21299 99 return 0;
21300 99 }
21301
21302 /*
21303 switch (ret) {
21304 case 0:
21305 break;
21306
21307 case qe_invalid:
21308 goto invalid;
21309 break;
21310 default:
21311 pack_fclose(f);
21312 if(!oldquest)
21313 delete_file(tmpfilename);
21314 return ret;
21315 break;
21316 }
21317 */
21318
21319 const char *skip_text[skip_max]=
21320 {
21321 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21322 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21323 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21324 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21325 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21326 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21327 "skip_favorites"
21328 };
21329
21330
21331 void port250QuestRules(){
21332
21333 portCandleRules(); //Candle
21334 portBombRules();
21335
21336 }
21337
21338 void portCandleRules()
21339 {
21340 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21341 //itemdata itemsbuf;
21342 for ( int32_t q = 0; q < MAXITEMS; q++ )
21343 {
21344 if ( itemsbuf[q].family == itype_candle )
21345 {
21346 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21347 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21348 }
21349 }
21350 }
21351
21352 void portBombRules()
21353 {
21354 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21355 //itemdata itemsbuf;
21356 for ( int32_t q = 0; q < MAXITEMS; q++ )
21357 {
21358 if ( itemsbuf[q].family == itype_bomb )
21359 {
21360 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21361 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21362 }
21363 }
21364
21365 }
21366
21367 //Internal function for loadquest wrapper
21368 108 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21369 {
21370 108 DMapEditorLastMaptileUsed = 0;
21371 108 combosread=false;
21372 108 mapsread=false;
21373 108 fixffcs=false;
21374
21375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21376 {
21377 keepall=false;
21378 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21379 }
21380
21381 // show_progress=true;
21382 char tmpfilename[L_tmpnam];
21383 108 temp_name(tmpfilename);
21384 // char percent_done[30];
21385 108 bool catchup=false;
21386 byte tempbyte;
21387 108 word old_map_count=map_count;
21388
21389 108 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21390 108 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21391 108 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21392
21393
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall==false||get_bit(skip_flags, skip_rules))
21394 {
21395 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21396 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21397 }
21398
21399 108 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21400 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21401
21402
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall==false||get_bit(skip_flags, skip_midis))
21403 {
21404 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21405 }
21406
21407
21408
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21409 {
21410 108 zScript.clear();
21411 108 globalmap.clear();
21412 108 genericmap.clear();
21413 108 ffcmap.clear();
21414 108 itemmap.clear();
21415 108 npcmap.clear();
21416 108 ewpnmap.clear();
21417 108 lwpnmap.clear();
21418 108 playermap.clear();
21419 108 dmapmap.clear();
21420 108 screenmap.clear();
21421 108 itemspritemap.clear();
21422 108 comboscriptmap.clear();
21423
21424
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21425 {
21426 55188 ffcmap[i].clear();
21427 55188 }
21428
21429 108 globalmap[0].slotname = "Slot 1:";
21430 108 globalmap[0].scriptname = "~Init";
21431 108 globalmap[0].update();
21432
21433
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 108 times.
864 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21434 {
21435 756 globalmap[i].clear();
21436 756 }
21437
21438
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21439 {
21440 27540 itemmap[i].clear();
21441 27540 }
21442
21443 //new script types -- prevent carrying over to a quest that you load after reading them
21444 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21445
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21446 {
21447 27540 npcmap[i].clear();
21448 27540 }
21449
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21450 {
21451 27540 lwpnmap[i].clear();
21452 27540 }
21453
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21454 {
21455 27540 ewpnmap[i].clear();
21456 27540 }
21457
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 108 times.
540 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21458 {
21459 432 playermap[i].clear();
21460 432 }
21461
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21462 {
21463 27540 dmapmap[i].clear();
21464 27540 }
21465
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21466 {
21467 27540 screenmap[i].clear();
21468 27540 }
21469
2/2
✓ Branch 0 taken 27540 times.
✓ Branch 1 taken 108 times.
27648 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21470 {
21471 27540 itemspritemap[i].clear();
21472 27540 }
21473
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21474 {
21475 55188 comboscriptmap[i].clear();
21476 55188 }
21477
2/2
✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 108 times.
55296 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21478 {
21479 55188 genericmap[i].clear();
21480 55188 }
21481
21482 108 reset_scripts();
21483 108 }
21484
21485 zquestheader tempheader;
21486 108 memset(&tempheader, 0, sizeof(zquestheader));
21487 108 zinfo tempzi;
21488 108 tempzi.clear();
21489 108 load_tmp_zi = &tempzi;
21490
21491 // oldquest flag is set when an unencrypted qst file is suspected.
21492 108 bool oldquest = false;
21493 108 int32_t open_error=0;
21494 108 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21495
21496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!f)
21497 return open_error;
21498 char zinfofilename[2048];
21499 108 replace_extension(zinfofilename, filename, "zinfo", 2047);
21500 108 int32_t ret=0;
21501
21502 //header
21503 108 box_out("Reading Header...");
21504 108 ret=readheader(f, &tempheader, true, printmetadata);
21505
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
108 checkstatus(ret);
21506 108 box_out("okay.");
21507 108 box_eol();
21508
21509
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 24 times.
108 if(read_zinfo)
21510 {
21511 24 box_out("Reading ZInfo - ");
21512
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23 times.
24 box_out(read_ext_zinfo ? "External..." : "Internal...");
21513
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23 times.
24 if(read_ext_zinfo)
21514 {
21515 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21516 1 ret=readzinfo(inf, tempzi, tempheader);
21517
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21518
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21519 1 }
21520 else
21521 {
21522 23 ret=readzinfo(f, tempzi, tempheader);
21523
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
23 checkstatus(ret);
21524 }
21525 24 box_out("okay.");
21526 24 box_eol();
21527 24 }
21528
21529
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if(tempheader.zelda_version>=0x193)
21530 {
21531 dword section_id;
21532
21533 //section id
21534
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_mgetl(&section_id,f,true))
21535 {
21536 return qe_invalid;
21537 }
21538
21539
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 104 times.
2555 while(!pack_feof(f))
21540 {
21541
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 104 times.
✓ Branch 6 taken 99 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 104 times.
✓ Branch 9 taken 104 times.
✓ Branch 10 taken 104 times.
✓ Branch 11 taken 104 times.
✓ Branch 12 taken 104 times.
✓ Branch 13 taken 99 times.
✓ Branch 14 taken 99 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 104 times.
✓ Branch 17 taken 99 times.
✓ Branch 18 taken 99 times.
✓ Branch 19 taken 99 times.
✓ Branch 20 taken 99 times.
✓ Branch 21 taken 104 times.
✓ Branch 22 taken 104 times.
✓ Branch 23 taken 99 times.
✓ Branch 24 taken 99 times.
2451 switch(section_id)
21542 {
21543 case ID_RULES:
21544
21545 //rules
21546
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21547 {
21548 box_out("found.");
21549 box_eol();
21550 catchup=false;
21551 }
21552
21553 104 box_out("Reading Rules...");
21554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21555
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21556 104 box_out("okay.");
21557 104 box_eol();
21558 104 break;
21559
21560 case ID_STRINGS:
21561
21562 //strings
21563
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21564 {
21565 box_out("found.");
21566 box_eol();
21567 catchup=false;
21568 }
21569
21570 104 box_out("Reading Strings...");
21571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21572
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21573 104 box_out("okay.");
21574 104 box_eol();
21575 104 break;
21576
21577 case ID_MISC:
21578
21579 //misc data
21580
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21581 {
21582 box_out("found.");
21583 box_eol();
21584 catchup=false;
21585 }
21586
21587 104 box_out("Reading Misc. Data...");
21588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21589
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21590 104 box_out("okay.");
21591 104 box_eol();
21592 104 break;
21593
21594 case ID_TILES:
21595
21596 //tiles
21597
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21598 {
21599 box_out("found.");
21600 box_eol();
21601 catchup=false;
21602 }
21603
21604 104 box_out("Reading Tiles...");
21605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21606
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21607 104 box_out("okay.");
21608 104 box_eol();
21609 104 break;
21610
21611 case ID_COMBOS:
21612
21613 //combos
21614
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21615 {
21616 box_out("found.");
21617 box_eol();
21618 catchup=false;
21619 }
21620
21621 104 box_out("Reading Combos...");
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21623 104 combosread=true;
21624
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21625 104 box_out("okay.");
21626 104 box_eol();
21627 104 break;
21628
21629 case ID_COMBOALIASES:
21630
21631 //combo aliases
21632
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21633 {
21634 box_out("found.");
21635 box_eol();
21636 catchup=false;
21637 }
21638
21639 99 box_out("Reading Combo Aliases...");
21640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21641
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21642 99 box_out("okay.");
21643 99 box_eol();
21644 99 break;
21645
21646 case ID_CSETS:
21647
21648 //color data
21649
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21650 {
21651 box_out("found.");
21652 box_eol();
21653 catchup=false;
21654 }
21655
21656 104 box_out("Reading Color Data...");
21657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21658
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21659 104 box_out("okay.");
21660 104 box_eol();
21661 104 break;
21662
21663 case ID_MAPS:
21664
21665 //maps
21666
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21667 {
21668 box_out("found.");
21669 box_eol();
21670 catchup=false;
21671 }
21672
21673 104 box_out("Reading Maps...");
21674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21675 104 mapsread=true;
21676
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21677 104 box_out("okay.");
21678 104 box_eol();
21679 104 break;
21680
21681 case ID_DMAPS:
21682
21683 //dmaps
21684
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21685 {
21686 box_out("found.");
21687 box_eol();
21688 catchup=false;
21689 }
21690
21691 104 box_out("Reading DMaps...");
21692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21693
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21694 104 box_out("okay.");
21695 104 box_eol();
21696 104 break;
21697
21698 case ID_DOORS:
21699
21700 //door combo sets
21701
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21702 {
21703 box_out("found.");
21704 box_eol();
21705 catchup=false;
21706 }
21707
21708 104 box_out("Reading Doors...");
21709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21710
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21711 104 box_out("okay.");
21712 104 box_eol();
21713 104 break;
21714
21715 case ID_ITEMS:
21716
21717 //items
21718
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21719 {
21720 box_out("found.");
21721 box_eol();
21722 catchup=false;
21723 }
21724
21725 104 box_out("Reading Items...");
21726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21727
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21728
21729 104 box_out("okay.");
21730 104 box_eol();
21731 104 break;
21732
21733 case ID_WEAPONS:
21734
21735 //weapons
21736
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21737 {
21738 box_out("found.");
21739 box_eol();
21740 catchup=false;
21741 }
21742
21743 104 box_out("Reading Weapons...");
21744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21745
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21746 104 box_out("okay.");
21747 104 box_eol();
21748 104 break;
21749
21750 case ID_COLORS:
21751
21752 //misc. colors
21753
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21754 {
21755 box_out("found.");
21756 box_eol();
21757 catchup=false;
21758 }
21759
21760 99 box_out("Reading Misc. Colors...");
21761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21762
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21763 99 box_out("okay.");
21764 99 box_eol();
21765 99 break;
21766
21767 case ID_ICONS:
21768
21769 //game icons
21770
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21771 {
21772 box_out("found.");
21773 box_eol();
21774 catchup=false;
21775 }
21776
21777 99 box_out("Reading Game Icons...");
21778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21779
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21780 99 box_out("okay.");
21781 99 box_eol();
21782 99 break;
21783
21784 case ID_INITDATA:
21785
21786 //initialization data
21787
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21788 {
21789 box_out("found.");
21790 box_eol();
21791 catchup=false;
21792 }
21793
21794 104 box_out("Reading Init. Data...");
21795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21796
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21797 104 box_out("okay.");
21798 104 box_eol();
21799
21800
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21801 {
21802
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 18 times.
104 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21803 {
21804 18 setupsubscreens();
21805
21806
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t i=0; i<MAXDMAPS; ++i)
21807 {
21808 9216 int32_t type=DMaps[i].type&dmfTYPE;
21809
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 9123 times.
9216 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21810 9216 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21811 9216 }
21812 18 }
21813 104 }
21814
21815
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_sfx))
21816 {
21817 104 setupsfx();
21818 104 }
21819
21820
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21821 {
21822 104 init_item_drop_sets();
21823 104 }
21824
21825
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_favorites))
21826 {
21827 104 init_favorites();
21828 104 }
21829
21830 104 break;
21831
21832 case ID_GUYS:
21833
21834 //guys
21835
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21836 {
21837 box_out("found.");
21838 box_eol();
21839 catchup=false;
21840 }
21841
21842 104 box_out("Reading Custom Guy Data...");
21843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21844
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21845 104 box_out("okay.");
21846 104 box_eol();
21847 104 break;
21848
21849 case ID_HEROSPRITES:
21850
21851 //player sprites
21852
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21853 {
21854 box_out("found.");
21855 box_eol();
21856 catchup=false;
21857 }
21858
21859 99 box_out("Reading Custom Player Sprite Data...");
21860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21861
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21862 99 box_out("okay.");
21863 99 box_eol();
21864 99 break;
21865
21866 case ID_SUBSCREEN:
21867
21868 //custom subscreens
21869
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21870 {
21871 box_out("found.");
21872 box_eol();
21873 catchup=false;
21874 }
21875
21876 99 box_out("Reading Custom Subscreen Data...");
21877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21878
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21879 99 box_out("okay.");
21880 99 box_eol();
21881 99 break;
21882
21883 case ID_FFSCRIPT:
21884
21885 //Freeform combo scripts
21886
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21887 {
21888 box_out("found.");
21889 box_eol();
21890 catchup=false;
21891 }
21892
21893 99 box_out("Reading FF Script Data...");
21894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21895
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21896 99 box_out("okay.");
21897 99 box_eol();
21898 99 break;
21899
21900 case ID_SFX:
21901
21902 //SFX data
21903
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21904 {
21905 box_out("found.");
21906 box_eol();
21907 catchup=false;
21908 }
21909
21910 99 box_out("Reading SFX Data...");
21911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21912
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21913 99 box_out("okay.");
21914 99 box_eol();
21915 99 break;
21916
21917 case ID_MIDIS:
21918
21919 //midis
21920
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21921 {
21922 box_out("found.");
21923 box_eol();
21924 catchup=false;
21925 }
21926
21927 104 box_out("Reading Tunes...");
21928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21929
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21930 104 box_out("okay.");
21931 104 box_eol();
21932 104 break;
21933
21934 case ID_CHEATS:
21935
21936 //cheat codes
21937
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(catchup)
21938 {
21939 box_out("found.");
21940 box_eol();
21941 catchup=false;
21942 }
21943
21944 104 box_out("Reading Cheat Codes...");
21945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21946
1/5
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21947 104 box_out("okay.");
21948 104 box_eol();
21949 104 break;
21950
21951 case ID_ITEMDROPSETS:
21952
21953 //item drop sets
21954
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21955 {
21956 box_out("found.");
21957 box_eol();
21958 catchup=false;
21959 }
21960
21961 99 box_out("Reading Item Drop Sets...");
21962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21963
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21964 99 box_out("okay.");
21965 99 box_eol();
21966 99 break;
21967
21968 case ID_FAVORITES:
21969
21970 //favorite combos and combo aliases
21971
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21972 {
21973 box_out("found.");
21974 box_eol();
21975 catchup=false;
21976 }
21977
21978 99 box_out("Reading Favorite Combos...");
21979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21980
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21981 99 box_out("okay.");
21982 99 box_eol();
21983 99 break;
21984
21985 default:
21986 if(!catchup)
21987 {
21988 box_out("Bad token! Searching...");
21989 box_eol();
21990 }
21991
21992 catchup=true;
21993 break;
21994 }
21995
21996
21997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2451 times.
2451 if(catchup)
21998 {
21999 //section id
22000 section_id=(section_id<<8);
22001
22002 if(!p_getc(&tempbyte,f,true))
22003 {
22004 return qe_invalid;
22005 }
22006
22007 section_id+=tempbyte;
22008 }
22009
22010 else
22011 {
22012 //section id
22013
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 2347 times.
2451 if(!pack_feof(f))
22014 {
22015
1/2
✓ Branch 0 taken 2347 times.
✗ Branch 1 not taken.
2347 if(!p_mgetl(&section_id,f,true))
22016 {
22017 return qe_invalid;
22018 }
22019 2347 }
22020 }
22021 }
22022 104 }
22023 else
22024 {
22025 //rules
22026 4 box_out("Reading Rules...");
22027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22028
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22029 4 box_out("okay.");
22030 4 box_eol();
22031
22032 //strings
22033 4 box_out("Reading Strings...");
22034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22035
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22036 4 box_out("okay.");
22037 4 box_eol();
22038
22039 //door combo sets
22040 4 box_out("Reading Doors...");
22041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22042
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22043 4 box_out("okay.");
22044 4 box_eol();
22045
22046 //dmaps
22047 4 box_out("Reading DMaps...");
22048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22049
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22050 4 box_out("okay.");
22051 4 box_eol();
22052
22053 // misc data
22054 4 box_out("Reading Misc. Data...");
22055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22056
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22057 4 box_out("okay.");
22058 4 box_eol();
22059
22060 //items
22061 4 box_out("Reading Items...");
22062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22063
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22064 4 box_out("okay.");
22065 4 box_eol();
22066
22067 //weapons
22068 4 box_out("Reading Weapons...");
22069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22070
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22071 4 box_out("okay.");
22072 4 box_eol();
22073
22074 //guys
22075 4 box_out("Reading Custom Guy Data...");
22076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22077
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22078 4 box_out("okay.");
22079 4 box_eol();
22080
22081 //maps
22082 4 box_out("Reading Maps...");
22083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22084 4 mapsread=true;
22085
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22086 4 box_out("okay.");
22087 4 box_eol();
22088
22089 //combos
22090 4 box_out("Reading Combos...");
22091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22092 4 combosread=true;
22093
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22094 4 box_out("okay.");
22095 4 box_eol();
22096
22097 //color data
22098 4 box_out("Reading Color Data...");
22099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22100
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22101 4 box_out("okay.");
22102 4 box_eol();
22103
22104 //tiles
22105 4 box_out("Reading Tiles...");
22106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22107
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22108 4 box_out("okay.");
22109 4 box_eol();
22110
22111 //midis
22112 4 box_out("Reading Tunes...");
22113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22114
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22115 4 box_out("okay.");
22116 4 box_eol();
22117
22118 //cheat codes
22119 4 box_out("Reading Cheat Codes...");
22120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22121
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22122 4 box_out("okay.");
22123 4 box_eol();
22124
22125 //initialization data
22126 4 box_out("Reading Init. Data...");
22127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22128
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22129 4 box_out("okay.");
22130 4 box_eol();
22131
22132
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22133 {
22134 4 setupsubscreens();
22135
22136
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22137 {
22138 2048 int32_t type=DMaps[i].type&dmfTYPE;
22139
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22140 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22141 2048 }
22142 4 }
22143
22144 4 box_out("Setting Up Default Sound Effects...");
22145
22146
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22147 4 setupsfx();
22148
22149 4 box_out("okay.");
22150 4 box_eol();
22151
22152 //player sprites
22153 4 box_out("Reading Custom Player Sprite Data...");
22154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22155
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22156 4 box_out("okay.");
22157 4 box_eol();
22158
22159 4 box_out("Setting Up Default Item Drop Sets...");
22160
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22161 4 box_out("okay.");
22162 4 box_eol();
22163 }
22164
22165 108 init_spritelists();
22166
22167 // check data
22168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(f)
22169 {
22170 108 pack_fclose(f);
22171 108 }
22172
22173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!oldquest)
22174 {
22175
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(exists(tmpfilename))
22176 {
22177 delete_file(tmpfilename);
22178 }
22179 108 }
22180
22181
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
108 if(fixffcs && combosread && mapsread)
22182 {
22183 for(int32_t i=0; i<map_count; i++)
22184 {
22185 for(int32_t j=0; j<MAPSCRS; j++)
22186 {
22187 for(int32_t m=0; m<32; m++)
22188 {
22189 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22190 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22191 }
22192 }
22193 }
22194 }
22195
22196
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 22 times.
108 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22197 {
22198 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22199 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22200 22 zinit.cont_heart=100;
22201 22 zinit.start_heart=zinit.hc;
22202 22 }
22203
22204 108 box_out("Done.");
22205 108 box_eol();
22206 108 box_end(false);
22207
22208 // if (keepall==true||!get_bit(skip_flags, skip_header))
22209
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_header))
22210 {
22211 108 memcpy(Header, &tempheader, sizeof(tempheader));
22212 108 }
22213
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22214 {
22215 108 ZI.copyFrom(tempzi);
22216 108 }
22217
22218
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_maps))
22219 {
22220 map_count=old_map_count;
22221 }
22222
22223
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_rules))
22224 {
22225 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22226 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22227 }
22228
22229
2/4
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
108 if(!keepall||get_bit(skip_flags, skip_midis))
22230 {
22231 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22232 }
22233
22234 //Debug FFCore.quest_format[]
22235 108 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22236 108 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22237 108 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22238 108 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22239 108 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22240 108 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22241 108 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22242 108 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22243 108 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22244 108 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22245 108 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22246 108 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22247 108 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22248 108 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22249 108 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22250 108 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22251 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22252 108 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22253 108 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22254 108 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22255 108 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22256 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22257 108 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22258 108 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22259 108 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22260 108 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22261 108 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22262 108 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22263 108 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22264 108 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22265 //Print metadata for versions under 2.10 here. Bleah.
22266
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 4 times.
108 if( FFCore.quest_format[vZelda] < 0x210 )
22267 {
22268 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22269
22270
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22271 {
22272 case 0x193:
22273 {
22274 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22275 }
22276 case 0x192:
22277 {
22278 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22279 }
22280 case 0x190:
22281 {
22282 4 zprint2("Last saved in ZC Editor Version: 1.90");
22283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22284 4 else zprint2("\n");
22285 4 break;
22286 }
22287 case 0x188:
22288 {
22289 zprint2("Last saved in ZC Editor Version: 1.88");
22290 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22291 else zprint2("\n");
22292 break;
22293 }
22294 case 0x187:
22295 {
22296 zprint2("Last saved in ZC Editor Version: 1.87");
22297 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22298 else zprint2("\n");
22299 break;
22300 }
22301 case 0x186:
22302 {
22303 zprint2("Last saved in ZC Editor Version: 1.86");
22304 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22305 else zprint2("\n");
22306 break;
22307 }
22308 case 0x185:
22309 {
22310 zprint2("Last saved in ZC Editor Version: 1.85");
22311 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22312 else zprint2("\n");
22313 break;
22314 }
22315 case 0x184:
22316 {
22317 zprint2("Last saved in ZC Editor Version: 1.84");
22318 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22319 else zprint2("\n");
22320 break;
22321 }
22322 case 0x183:
22323 {
22324 zprint2("Last saved in ZC Editor Version: 1.83");
22325 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22326 else zprint2("\n");
22327 break;
22328 }
22329 case 0x182:
22330 {
22331 zprint2("Last saved in ZC Editor Version: 1.82");
22332 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22333 else zprint2("\n");
22334 break;
22335 }
22336 case 0x181:
22337 {
22338 zprint2("Last saved in ZC Editor Version: 1.81");
22339 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22340 else zprint2("\n");
22341 break;
22342 }
22343 case 0x180:
22344 {
22345 zprint2("Last saved in ZC Editor Version: 1.80");
22346 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22347 else zprint2("\n");
22348 break;
22349 }
22350 default:
22351 {
22352 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22353 }
22354 }
22355 4 }
22356
22357 108 return qe_OK;
22358
22359 invalid:
22360 box_out("error.");
22361 box_eol();
22362 box_end(true);
22363
22364 if(f)
22365 {
22366 pack_fclose(f);
22367 }
22368
22369 if(!oldquest)
22370 {
22371 if(exists(tmpfilename))
22372 {
22373 delete_file(tmpfilename);
22374 }
22375 }
22376
22377 return qe_invalid;
22378
22379 108 }
22380
22381 108 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22382 {
22383 108 loading_qst_name = filename;
22384 108 loading_qst_num = qst_num;
22385 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22386 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22387
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if (!is_ci())
22388 loadquest_report = report;
22389 108 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22390 108 load_tmp_zi = NULL;
22391 108 loading_qst_name = NULL;
22392 108 loadquest_report = false;
22393 108 loading_qst_num = 0;
22394 108 return ret;
22395 }
22396 /*** end of qst.cc ***/
22397
22398